diff options
author | varobert <varobert@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2012-04-13 08:35:21 +0000 |
---|---|---|
committer | varobert <varobert@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2012-04-13 08:35:21 +0000 |
commit | 3f205ff4314ccac92e4d74951929aa31b0308274 (patch) | |
tree | 7d7d939b918f0a2be8423c66a5c47346145d4eaa /checklink/ELF_utils.ml | |
parent | acec11c3a6f9364eaabe398de6e65ccff510bf39 (diff) | |
download | compcert-3f205ff4314ccac92e4d74951929aa31b0308274.tar.gz compcert-3f205ff4314ccac92e4d74951929aa31b0308274.zip |
New section mapping checks and symbol data lookup
Section mapping is now discovered on-the-fly, and linker script remappings
are reported as warnings at the end. Symbol data lookup is now able to
gracefully fail if the symbol's virtual address is not within the range of
its parent section's virtual address space.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1878 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'checklink/ELF_utils.ml')
-rw-r--r-- | checklink/ELF_utils.ml | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/checklink/ELF_utils.ml b/checklink/ELF_utils.ml index 5244dc83..4d901600 100644 --- a/checklink/ELF_utils.ml +++ b/checklink/ELF_utils.ml @@ -35,20 +35,26 @@ let section_at_vaddr (e: elf)(vaddr: int32): int option = *) let bitstring_at_vaddr e sndx vaddr size = let shdr = e.e_shdra.(sndx) in - let bs = section_bitstring e sndx in - let bit_ofs = Safe.(8 * Safe32.(to_int (vaddr - shdr.sh_addr))) in - Bitstring.subbitstring bs bit_ofs size + if vaddr < shdr.sh_addr || Safe32.(shdr.sh_addr + shdr.sh_size) <= vaddr + then None + else + let bs = section_bitstring e sndx in + let bit_ofs = Safe.(8 * Safe32.(to_int (vaddr - shdr.sh_addr))) in + Some(Bitstring.subbitstring bs bit_ofs size) (** Returns the entire bitstring that begins at the specified virtual address within the specified section and ends at the end of the file. This is useful when you don't know the sections size yet. *) -let bitstring_at_vaddr_nosize (e: elf)(sndx: int)(vaddr: int32): bitstring = +let bitstring_at_vaddr_nosize (e: elf)(sndx: int)(vaddr: int32): bitstring option = let shdr = e.e_shdra.(sndx) in - let bs = section_bitstring e sndx in - let bit_ofs = Safe.(8 * Safe32.(to_int (vaddr - shdr.sh_addr))) in - Bitstring.dropbits bit_ofs bs + if vaddr < shdr.sh_addr || Safe32.(shdr.sh_addr + shdr.sh_size) <= vaddr + then None + else + let bs = section_bitstring e sndx in + let bit_ofs = Safe.(8 * Safe32.(to_int (vaddr - shdr.sh_addr))) in + Some(Bitstring.dropbits bit_ofs bs) (** Removes symbol version for GCC's symbols. |