PR20659, Objcopy and change section lma failing
authorAlan Modra <amodra@gmail.com>
Fri, 11 May 2018 05:04:48 +0000 (14:34 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 12 May 2018 06:33:44 +0000 (16:03 +0930)
commit9933dc52736dd349503e00a68cd0b9be4388f5a9
tree7ba01b8f0f8c24ef86901868989788aebc7b1e75
parentc64c5aae285146dce98f651d175f2ad1a437074f
PR20659, Objcopy and change section lma failing

Sections may well belong in multiple segments.  The testcase in the PR
saw an allocated section being assigned to an ABIFLAGS segment, then
not being assigned to a LOAD segment because it had already been
handled.  To fix that particular problem this patch sets and tests
segment_mark only for LOAD segments.  I kept the segment_mark test for
LOAD segments because I think there may otherwise be a problem with
zero size sections.

A few other problems showed up with the testcase.  Some targets align
.dynamic, resulting in the test failing with "section .dynamic lma
0x800000c0 adjusted to 0x800000cc" and similar messages.  I've tried
to handle that with some more hacks to the segment lma, which do the
right thing for the testcase, but may well fail in other situations.

I've also removed the tests of segment lma (p_paddr) and code involved
in deciding that an adjusted segment no longer covers the file or
program headers.  Those test can't be correct in the face of objcopy
--change-section-lma.  It may be necessary to reinstate the tests but
do them modulo page size, but we'll see how this goes.

PR 20659
bfd/
* elf.c (rewrite_elf_program_header): Use segment_mark only for
PT_LOAD headers.  Delete first_matching_lma and first_suggested_lma.
Instead make matching_lma and suggested_lma pointers to the
sections.  Align section vma and lma calculated from segment.
Don't clear includes_phdrs or includes_filehdr based on p_paddr
test.  Try to handle alignment padding before first section by
adjusting new segment lma down.  Adjust PT_PHDR map p_paddr.
ld/
* testsuite/ld-elf/changelma.d,
* testsuite/ld-elf/changelma.lnk,
* testsuite/ld-elf/changelma.s: New test.
bfd/ChangeLog
bfd/elf.c
ld/ChangeLog
ld/testsuite/ld-elf/changelma.d [new file with mode: 0644]
ld/testsuite/ld-elf/changelma.lnk [new file with mode: 0644]
ld/testsuite/ld-elf/changelma.s [new file with mode: 0644]
This page took 0.030231 seconds and 4 git commands to generate.