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
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++)
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
+2016-12-13 Alan Modra <amodra@gmail.com>
+
+ * 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.
+
2016-12-08 Alan Modra <amodra@gmail.com>
* configure: Regenerate.
set exec_output [prune_warnings $exec_output]
verbose -log $exec_output
- # The RX port sets the p_paddr of loadable segments to 0 in order
- # to be compatible with Renesas tools. When an RX executable is
- # loaded into a BFD based tool the code tries to reconstruct the
- # correct vaddr and paddr values. This is not always possible
- # however and this test is one example of where the reconstruction
- # fails.
- setup_xfail rx-*-*
-
if [regexp $phdrs_regexp $exec_output] {
pass $testname
} else {