Use offsets instead of addresses in ELF_SECTION_IN_SEGMENT for non SHT_NOBITS
authorAlan Hayward <alan.hayward@arm.com>
Thu, 21 Jun 2018 08:37:58 +0000 (09:37 +0100)
committerAlan Hayward <alan.hayward@arm.com>
Thu, 21 Jun 2018 08:37:58 +0000 (09:37 +0100)
For sections that are not SHT_NOBITS, use sh_offset and p_offset instead of
sh_addr and p_vaddr when calculating if a section fits in a segment. Both
methods are valid when using the GNU linker.

include/
* elf/internal.h (ELF_SECTION_IN_SEGMENT): Don’t check addresses
for non SHT_NOBITS.

include/ChangeLog
include/elf/internal.h

index b8a0a2324d75d1326d1c11db10be1d57893d98da..f5fdf43166b02b5c5af2d6313ca369459f926b25 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-21  Alan Hayward  <alan.hayward@arm.com>
+
+       * elf/internal.h (ELF_SECTION_IN_SEGMENT): Don’t check addresses
+       for non SHT_NOBITS.
+
 2018-06-19  Simon Marchi  <simon.marchi@ericsson.com>
 
        Sync with GCC
index 05f9fab89cbe2aee94006d18a689cb01e101776f..b012820f6cf9c7e6b5879748b0b05685594987bb 100644 (file)
@@ -342,8 +342,10 @@ struct elf_segment_map
           && (((sec_hdr)->sh_offset - (segment)->p_offset              \
                + ELF_SECTION_SIZE(sec_hdr, segment))                   \
               <= (segment)->p_filesz)))                                \
-   /* SHF_ALLOC sections must have VMAs within the segment.  */                \
+   /* SHT_NOBITS sections with SHF_ALLOC must have VMAs within the     \
+      segment.  */                                                     \
    && (!(check_vma)                                                    \
+       || (sec_hdr)->sh_type != SHT_NOBITS                             \
        || ((sec_hdr)->sh_flags & SHF_ALLOC) == 0                       \
        || ((sec_hdr)->sh_addr >= (segment)->p_vaddr                    \
           && (!(strict)                                                \
This page took 0.034799 seconds and 4 git commands to generate.