aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2002-04-03 13:26:34 +0000
committerAlan Modra <amodra@gmail.com>2002-04-03 13:26:34 +0000
commitd7866f045984f643f1be489ddf396d21fd59b389 (patch)
tree50ae6ca03a612a49ce5ab8975111c7440e62f510 /bfd
parent50e60fb5787f9df6a34bfef4ecf7eb28c28acb74 (diff)
downloadgdb-d7866f045984f643f1be489ddf396d21fd59b389.zip
gdb-d7866f045984f643f1be489ddf396d21fd59b389.tar.gz
gdb-d7866f045984f643f1be489ddf396d21fd59b389.tar.bz2
* elf.c (_bfd_elf_make_section_from_shdr): When setting section
LMAs, loop over segments until p_vaddr and p_memsz specify an extent enclosing the section.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf.c17
2 files changed, 19 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 1c335a1..4093a38 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2002-04-03 Alan Modra <amodra@bigpond.net.au>
+
+ * elf.c (_bfd_elf_make_section_from_shdr): When setting section
+ LMAs, loop over segments until p_vaddr and p_memsz specify an
+ extent enclosing the section.
+
2002-04-02 Nick Clifton <nickc@cambridge.redhat.com>
* ihex.c (ihex_write_object_contents): Do not allow records to
diff --git a/bfd/elf.c b/bfd/elf.c
index 0def961..67d9add 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -665,11 +665,12 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name)
&& (hdr->sh_offset + hdr->sh_size
<= phdr->p_offset + phdr->p_memsz)
&& ((flags & SEC_LOAD) == 0
- || (phdr->p_offset + phdr->p_filesz
- >= hdr->sh_offset + hdr->sh_size)))
+ || (hdr->sh_offset + hdr->sh_size
+ <= phdr->p_offset + phdr->p_filesz)))
{
if ((flags & SEC_LOAD) == 0)
- newsect->lma += phdr->p_paddr - phdr->p_vaddr;
+ newsect->lma = (phdr->p_paddr
+ + hdr->sh_addr - phdr->p_vaddr);
else
/* We used to use the same adjustment for SEC_LOAD
sections, but that doesn't work if the segment
@@ -680,7 +681,15 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name)
LMAs, even if the VMAs are not. */
newsect->lma = (phdr->p_paddr
+ hdr->sh_offset - phdr->p_offset);
- break;
+
+ /* With contiguous segments, we can't tell from file
+ offsets whether a section with zero size should
+ be placed at the end of one segment or the
+ beginning of the next. Decide based on vaddr. */
+ if (hdr->sh_addr >= phdr->p_vaddr
+ && (hdr->sh_addr + hdr->sh_size
+ <= phdr->p_vaddr + phdr->p_memsz))
+ break;
}
}
}