* elf.c (_bfd_elf_make_section_from_shdr): For a loadable section,
authorIan Lance Taylor <ian@airs.com>
Mon, 5 Aug 1996 20:45:55 +0000 (20:45 +0000)
committerIan Lance Taylor <ian@airs.com>
Mon, 5 Aug 1996 20:45:55 +0000 (20:45 +0000)
only get the LMA from the phdr if they are in the same part of the
file.

bfd/ChangeLog
bfd/elf.c

index c3a057811de54d933c7c36fa26735603dc87aaa6..41a2e953c523e60c4a4b80198497057d1aca66bb 100644 (file)
@@ -1,5 +1,9 @@
 Mon Aug  5 13:42:41 1996  Ian Lance Taylor  <ian@cygnus.com>
 
+       * elf.c (_bfd_elf_make_section_from_shdr): For a loadable section,
+       only get the LMA from the phdr if they are in the same part of the
+       file.
+
        * elf.c (map_sections_to_segments): Rewrite tests for starting a
        new segment to make them more comprehensible.  If the relationship
        between the LMA and the VMA changed, start a new segment.  Don't
index 7eb5540fcf596962aad451f3a50e383830076af8..4978957833309a513d10d883eb62b0b3e4fa8f28 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -228,7 +228,11 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name)
              && phdr->p_paddr != 0
              && phdr->p_vaddr != phdr->p_paddr
              && phdr->p_vaddr <= hdr->sh_addr
-             && phdr->p_vaddr + phdr->p_memsz >= hdr->sh_addr + hdr->sh_size)
+             && phdr->p_vaddr + phdr->p_memsz >= hdr->sh_addr + hdr->sh_size
+             && ((flags & SEC_LOAD) == 0
+                 || (phdr->p_offset <= hdr->sh_offset
+                     && (phdr->p_offset + phdr->p_filesz
+                         >= hdr->sh_offset + hdr->sh_size))))
            {
              newsect->lma += phdr->p_paddr - phdr->p_vaddr;
              break;