aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-05-11 14:34:48 +0930
committerAlan Modra <amodra@gmail.com>2018-05-12 16:03:44 +0930
commit9933dc52736dd349503e00a68cd0b9be4388f5a9 (patch)
tree7ba01b8f0f8c24ef86901868989788aebc7b1e75 /ld
parentc64c5aae285146dce98f651d175f2ad1a437074f (diff)
downloadgdb-9933dc52736dd349503e00a68cd0b9be4388f5a9.zip
gdb-9933dc52736dd349503e00a68cd0b9be4388f5a9.tar.gz
gdb-9933dc52736dd349503e00a68cd0b9be4388f5a9.tar.bz2
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.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog7
-rw-r--r--ld/testsuite/ld-elf/changelma.d12
-rw-r--r--ld/testsuite/ld-elf/changelma.lnk11
-rw-r--r--ld/testsuite/ld-elf/changelma.s2
4 files changed, 32 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 0cbb953..3360959 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2018-05-12 Alan Modra <amodra@gmail.com>
+
+ PR 20659
+ * testsuite/ld-elf/changelma.d,
+ * testsuite/ld-elf/changelma.lnk,
+ * testsuite/ld-elf/changelma.s: New test.
+
2018-05-09 2018-05-02 Dimitar Dimitrov <dimitar@dinux.eu>
* scripttempl/pru.sc: Add LD sections to allow linking TI
diff --git a/ld/testsuite/ld-elf/changelma.d b/ld/testsuite/ld-elf/changelma.d
new file mode 100644
index 0000000..858a8db
--- /dev/null
+++ b/ld/testsuite/ld-elf/changelma.d
@@ -0,0 +1,12 @@
+#name: changelma (pr20659)
+#ld: -T changelma.lnk
+#objcopy_linked_file: --change-section-lma .dynamic+0x80000000
+#readelf: -l --wide
+#xfail: rx-*-*
+# rx-elf fails since it forces vma equal to lma
+
+#...
+ PHDR +0x[0-9a-f]* 0x[0-9a-f]* 0x0*8000[0-9a-f]{4} .*
+ LOAD +0x0+ 0x0+ 0x0*80000000 .*
+ DYNAMIC +0x[0-9a-f]* 0x[0-9a-f]* 0x0*8000[0-9a-f]{4} .*
+#pass
diff --git a/ld/testsuite/ld-elf/changelma.lnk b/ld/testsuite/ld-elf/changelma.lnk
new file mode 100644
index 0000000..fd55516
--- /dev/null
+++ b/ld/testsuite/ld-elf/changelma.lnk
@@ -0,0 +1,11 @@
+PHDRS
+{
+ headers PT_PHDR PHDRS ;
+ text PT_LOAD FILEHDR PHDRS ;
+ dynamic PT_DYNAMIC ;
+}
+SECTIONS
+{
+ . = SIZEOF_HEADERS;
+ .dynamic : { *(*) } :text :dynamic
+}
diff --git a/ld/testsuite/ld-elf/changelma.s b/ld/testsuite/ld-elf/changelma.s
new file mode 100644
index 0000000..458b40e
--- /dev/null
+++ b/ld/testsuite/ld-elf/changelma.s
@@ -0,0 +1,2 @@
+ .text
+ .space 16