aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2008-05-19 06:06:03 +0000
committerAlan Modra <amodra@gmail.com>2008-05-19 06:06:03 +0000
commit6ffd79000b45e77b3625143932ffbf781b6aecab (patch)
treeea06bdf301bb4c57edb1a004dd9117eece27e608 /bfd
parent3ea4a8cb4ba46099caa26e67b78c68e88b4dc535 (diff)
downloadgdb-6ffd79000b45e77b3625143932ffbf781b6aecab.zip
gdb-6ffd79000b45e77b3625143932ffbf781b6aecab.tar.gz
gdb-6ffd79000b45e77b3625143932ffbf781b6aecab.tar.bz2
PR 2995, PR 6473
* elf.c (_bfd_elf_make_section_from_shdr): Leave lma equal to vma when all p_paddr fields are zero and there is more than one PT_LOAD header.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elf.c15
2 files changed, 21 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8246fa7..ba07dad 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2008-05-19 Alan Modra <amodra@bigpond.net.au>
+
+ PR 2995, PR 6473
+ * elf.c (_bfd_elf_make_section_from_shdr): Leave lma equal to
+ vma when all p_paddr fields are zero and there is more than
+ one PT_LOAD header.
+
2008-05-15 Christophe Lyon <christophe.lyon@st.com>
Add long call support for ARM.
diff --git a/bfd/elf.c b/bfd/elf.c
index 20f4cb3..0280a03 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -948,7 +948,20 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
if ((flags & SEC_ALLOC) != 0)
{
Elf_Internal_Phdr *phdr;
- unsigned int i;
+ unsigned int i, nload;
+
+ /* Some ELF linkers produce binaries with all the program header
+ p_paddr fields zero. If we have such a binary with more than
+ one PT_LOAD header, then leave the section lma equal to vma
+ so that we don't create sections with overlapping lma. */
+ phdr = elf_tdata (abfd)->phdr;
+ for (nload = 0, i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
+ if (phdr->p_paddr != 0)
+ break;
+ else if (phdr->p_type == PT_LOAD && phdr->p_memsz != 0)
+ ++nload;
+ if (i >= elf_elfheader (abfd)->e_phnum && nload > 1)
+ return TRUE;
phdr = elf_tdata (abfd)->phdr;
for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)