* internal.h (ELF_IS_SECTION_IN_SEGMENT): Adjust to cope with
authorNathan Sidwell <nathan@codesourcery.com>
Wed, 28 Nov 2007 13:53:05 +0000 (13:53 +0000)
committerNathan Sidwell <nathan@codesourcery.com>
Wed, 28 Nov 2007 13:53:05 +0000 (13:53 +0000)
segments at the end of memory.

include/elf/ChangeLog
include/elf/internal.h

index fe6134ded89ccc6727ebde4bf26c10af73d364b0..ded6712636ab50b47a9cac43b7e0666a2fd8579f 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * internal.h (ELF_IS_SECTION_IN_SEGMENT): Adjust to cope with
+       segments at the end of memory.
+
 2007-11-16  Nick Clifton  <nickc@redhat.com>
 
        * dwarf2.h: Mention the location of the DWARF3 spec on the web.
index f5380b8d514da07ea22a93b0f491dc3c40f3e91a..93c2315e8d75d2913af4691c4adc6fbedc0697ed 100644 (file)
@@ -286,11 +286,12 @@ struct elf_segment_map
        || ((bfd_vma) sec_hdr->sh_offset >= segment->p_offset           \
           && (sec_hdr->sh_offset + ELF_SECTION_SIZE(sec_hdr, segment)  \
               <= segment->p_offset + segment->p_filesz)))              \
-   /* SHF_ALLOC sections must have VMAs within the segment.  */                \
+   /* SHF_ALLOC sections must have VMAs within the segment.  Be                \
+      careful about segments right at the end of memory.  */           \
    && ((sec_hdr->sh_flags & SHF_ALLOC) == 0                            \
        || (sec_hdr->sh_addr >= segment->p_vaddr                                \
-          && (sec_hdr->sh_addr + ELF_SECTION_SIZE(sec_hdr, segment)    \
-              <= segment->p_vaddr + segment->p_memsz))))
+          && (sec_hdr->sh_addr - segment->p_vaddr                      \
+              + ELF_SECTION_SIZE(sec_hdr, segment) <= segment->p_memsz))))
 
 /* Decide if the given sec_hdr is in the given segment in file.  */
 #define ELF_IS_SECTION_IN_SEGMENT_FILE(sec_hdr, segment)       \