aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2016-12-13 09:29:47 +1030
committerAlan Modra <amodra@gmail.com>2016-12-13 09:37:37 +1030
commit6392030005291f7c783da2247b63ae31dc8352e0 (patch)
treee969ae75f49bf5133ea7e5d69b9b36598efa2560 /bfd
parentea0ffd5be2dfd6ee696fc15294d7b2bf29f267a7 (diff)
downloadfsf-binutils-gdb-6392030005291f7c783da2247b63ae31dc8352e0.zip
fsf-binutils-gdb-6392030005291f7c783da2247b63ae31dc8352e0.tar.gz
fsf-binutils-gdb-6392030005291f7c783da2247b63ae31dc8352e0.tar.bz2
Don't fudge p_vaddr when PHDR in segment
RX does horrible fudges to PT_LOAD p_vaddr, that affect the testsuite and mean the target won't support dynamic objects. The latter probably doesn't matter too much since RX is an embedded target, but it's easy to stop some of the fudges in order to reduce special cases for RX in the testsuite. The changes make sense in isolation too. bfd/ * elf32-rx.c (elf32_rx_modify_program_headers): Don't adjust segments that include the ELF file header or program headers. ld/ * testsuite/ld-elf/flags1.d: Run for RX. * testsuite/ld-scripts/phdrs.exp: Likewise. * testsuite/ld-scripts/pr14962.d: Likewise. * testsuite/ld-scripts/pr14962-2.d: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf32-rx.c16
2 files changed, 20 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 1c1dd90..b461ebe 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2016-12-13 Alan Modra <amodra@gmail.com>
+
+ * elf32-rx.c (elf32_rx_modify_program_headers): Don't adjust
+ segments that include the ELF file header or program headers.
+
2016-12-08 Alan Modra <amodra@gmail.com>
PR ld/20932
diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c
index f5377c0..72ea7fd 100644
--- a/bfd/elf32-rx.c
+++ b/bfd/elf32-rx.c
@@ -3200,9 +3200,11 @@ rx_elf_object_p (bfd * abfd)
int i;
unsigned int u;
Elf_Internal_Phdr *phdr = elf_tdata (abfd)->phdr;
- int nphdrs = elf_elfheader (abfd)->e_phnum;
+ Elf_Internal_Ehdr *ehdr = elf_elfheader (abfd);
+ int nphdrs = ehdr->e_phnum;
sec_ptr bsec;
static int saw_be = FALSE;
+ bfd_vma end_phdroff;
/* We never want to automatically choose the non-swapping big-endian
target. The user can only get that explicitly, such as with -I
@@ -3227,6 +3229,17 @@ rx_elf_object_p (bfd * abfd)
corresponds (based on matching file offsets) and use its VMA
information to reconstruct the p_vaddr field we clobbered when we
wrote it out. */
+ /* If PT_LOAD headers include the ELF file header or program headers
+ then the PT_LOAD header does not start with some section contents.
+ Making adjustments based on the difference between sh_offset and
+ p_offset is nonsense in such cases. Exclude them. Note that
+ since standard linker scripts for RX do not use SIZEOF_HEADERS,
+ the linker won't normally create PT_LOAD segments covering the
+ headers so this is mainly for passing the ld testsuite.
+ FIXME. Why are we looking at non-PT_LOAD headers here? */
+ end_phdroff = ehdr->e_ehsize;
+ if (ehdr->e_phoff != 0)
+ end_phdroff = ehdr->e_phoff + nphdrs * ehdr->e_phentsize;
for (i=0; i<nphdrs; i++)
{
for (u=0; u<elf_tdata(abfd)->num_elf_sections; u++)
@@ -3234,6 +3247,7 @@ rx_elf_object_p (bfd * abfd)
Elf_Internal_Shdr *sec = elf_tdata(abfd)->elf_sect_ptr[u];
if (phdr[i].p_filesz
+ && phdr[i].p_offset >= end_phdroff
&& phdr[i].p_offset <= (bfd_vma) sec->sh_offset
&& sec->sh_size > 0
&& sec->sh_type != SHT_NOBITS