aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-02-06 19:42:52 -0800
committerH.J. Lu <hjl.tools@gmail.com>2020-02-06 19:43:03 -0800
commit9b538ba71fc7dbab65371e3e4e5f7e093ff25023 (patch)
treeda4c23f9a303106a0a01e1770034cfbeb112825d /ld/testsuite
parent5242a0a000ad7d3f2fa1cd0023f692d53261b302 (diff)
downloadgdb-9b538ba71fc7dbab65371e3e4e5f7e093ff25023.zip
gdb-9b538ba71fc7dbab65371e3e4e5f7e093ff25023.tar.gz
gdb-9b538ba71fc7dbab65371e3e4e5f7e093ff25023.tar.bz2
ELF: Discard a section if any of its linked-to sections has been discarded
Add ldelf_before_place_orphans to call before lang_place_orphans to discard a section if any of its linked-to sections has been discarded. PR ld/25022 * emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Add before_place_orphans_default. * emultempl/armcoff.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/beos.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/generic.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/linux.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/msp430.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/pe.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/pep.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/ticoff.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/vanilla.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Use ldelf_before_place_orphans. * ldelf.c (ldelf_before_place_orphans): New. * ldelf.h (ldelf_before_place_orphans): Likewise. * ldemul.c (ldemul_before_place_orphans): Likewise. (before_place_orphans_default): Likewise. * ldemul.h (ldemul_before_place_orphans): Likewise. (before_place_orphans_default): Likewise. (ld_emulation_xfer_struct): Add before_place_orphans. * ldlang.c (lang_process): Call ldemul_before_place_orphans before lang_place_orphans. * testsuite/ld-elf/pr25022.d: New file. * testsuite/ld-elf/pr25022.s: Likewise. * testsuite/ld-elf/pr25022.t: Likewise.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ld-elf/pr25022.d9
-rw-r--r--ld/testsuite/ld-elf/pr25022.s11
-rw-r--r--ld/testsuite/ld-elf/pr25022.t1
3 files changed, 21 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elf/pr25022.d b/ld/testsuite/ld-elf/pr25022.d
new file mode 100644
index 0000000..9a39752
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25022.d
@@ -0,0 +1,9 @@
+#ld: -T pr25022.t
+#readelf: -SW
+#xfail: msp*-*
+# msp* doesn't use ldelf_before_place_orphans.
+
+#failif
+#...
+ +\[ *[0-9]+\] \.(bar|moo|zed) +.*
+#...
diff --git a/ld/testsuite/ld-elf/pr25022.s b/ld/testsuite/ld-elf/pr25022.s
new file mode 100644
index 0000000..ace4f25
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25022.s
@@ -0,0 +1,11 @@
+ .section .foo,"a"
+ .dc.a 0
+
+ .section .moo,"ao",%progbits,.zed
+ .dc.a 0
+
+ .section .bar,"ao",%progbits,.foo
+ .dc.a 0
+
+ .section .zed,"ao",%progbits,.foo
+ .dc.a 0
diff --git a/ld/testsuite/ld-elf/pr25022.t b/ld/testsuite/ld-elf/pr25022.t
new file mode 100644
index 0000000..bb9aa81
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr25022.t
@@ -0,0 +1 @@
+SECTIONS { /DISCARD/ : { *(.foo) } }