summaryrefslogtreecommitdiff
path: root/checklink/PPC_utils.ml
diff options
context:
space:
mode:
authorGravatar varobert <varobert@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-05-10 07:53:57 +0000
committerGravatar varobert <varobert@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-05-10 07:53:57 +0000
commit521dac4e0d950e6128b266b27eac1875d79200f1 (patch)
treef8b73847a64c769264065c88a31a413f3c3511e4 /checklink/PPC_utils.ml
parenta6044b4a4d38354411cbf535472776f4d5bb30d5 (diff)
cchecklink now reads segments instead of sections
cchecklink is now using program header information to figure out the initial address space of the program, rather than the information in the parent section of each symbol. This decouples the resolution of symbols from inaccurate section information, reflecting more the actual program loading. Additionally, a -relaxed option has been added to deal with some strange ELFs, for instance when symbols data is dynamically bootstrapped from another place by boot code different than the program loader. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1893 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'checklink/PPC_utils.ml')
-rw-r--r--checklink/PPC_utils.ml25
1 files changed, 6 insertions, 19 deletions
diff --git a/checklink/PPC_utils.ml b/checklink/PPC_utils.ml
index 338c4c5..44d49d3 100644
--- a/checklink/PPC_utils.ml
+++ b/checklink/PPC_utils.ml
@@ -4,28 +4,17 @@ open Library
open PPC_parsers
open PPC_types
-let code_at_vaddr (e: elf) (vaddr: int32) (nb_instr: int): ecode option =
- begin match section_at_vaddr e vaddr with
+let code_at_vaddr (e: elf)(vaddr: int32)(nb_instr: int): ecode option =
+ begin match bitstring_at_vaddr e vaddr (Safe32.of_int (4 * nb_instr)) with
| None -> None
- | Some(sndx) ->
- begin match bitstring_at_vaddr e sndx vaddr (32 * nb_instr) with
- | None -> None
- | Some(code_bs) -> Some (parse_code_as_list code_bs)
- end
+ | Some(code_bs, _, _) -> Some (parse_code_as_list code_bs)
end
let code_of_sym_ndx (e: elf) (ndx: int): ecode option =
let sym = e.e_symtab.(ndx) in
- begin match sym.st_type with
- | STT_FUNC ->
- let sym_vaddr = sym.st_value in
- let sym_size = Safe.(of_int32 sym.st_size * 8) in
- let sym_sndx = sym.st_shndx in
- begin match bitstring_at_vaddr e sym_sndx sym_vaddr sym_size with
- | None -> None
- | Some(code_bs) -> Some (parse_code_as_list code_bs)
- end
- | _ -> None
+ begin match bitstring_at_vaddr e sym.st_value sym.st_size with
+ | None -> None
+ | Some(bs, _, _) -> Some(parse_code_as_list bs)
end
let code_of_sym_name (e: elf) (name: string): ecode option =
@@ -33,5 +22,3 @@ let code_of_sym_name (e: elf) (name: string): ecode option =
| Some ndx -> code_of_sym_ndx e ndx
| None -> None
end
-
-