aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-05-17 07:57:15 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-05-17 07:57:26 -0700
commitb7c871edcd83ccdc5fcd8148a7f433efd6b52255 (patch)
treed1f43eadeeac5387cca51b23a1b8e9da8aa0fbb6 /ld
parent0d5c69990c1992289f7b286600a43de4d5d44062 (diff)
downloadgdb-b7c871edcd83ccdc5fcd8148a7f433efd6b52255.zip
gdb-b7c871edcd83ccdc5fcd8148a7f433efd6b52255.tar.gz
gdb-b7c871edcd83ccdc5fcd8148a7f433efd6b52255.tar.bz2
Mark debug sections referenced by kept debug sections
If a debug section is referenced by a kept debug section, it should also be kept. Some targets, like mips, keep input files when there are some special sections, like .gnu.attributes, even if input file is unused otherwise. In this case, all debug sections are kept. The new test will fail on such targets. We can either fix those targets or XFAIL the test. bfd/ PR ld/20882 * elflink.c (elf_gc_mark_debug_section): New function. (_bfd_elf_gc_mark_extra_sections): Mark any debug sections referenced by kept debug sections. ld/ PR ld/20882 * testsuite/ld-gc/gc.exp: Run pr20882. * testsuite/ld-gc/pr20882.d: New file. * testsuite/ld-gc/pr20882a.s: Likewise. * testsuite/ld-gc/pr20882b.s: Likewise. * testsuite/ld-gc/pr20882c.s: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/testsuite/ld-gc/gc.exp1
-rw-r--r--ld/testsuite/ld-gc/pr20882.d10
-rw-r--r--ld/testsuite/ld-gc/pr20882a.s11
-rw-r--r--ld/testsuite/ld-gc/pr20882b.s8
-rw-r--r--ld/testsuite/ld-gc/pr20882c.s8
6 files changed, 47 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 2034a1a..b71bc16 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2017-05-17 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/20882
+ * testsuite/ld-gc/gc.exp: Run pr20882.
+ * testsuite/ld-gc/pr20882.d: New file.
+ * testsuite/ld-gc/pr20882a.s: Likewise.
+ * testsuite/ld-gc/pr20882b.s: Likewise.
+ * testsuite/ld-gc/pr20882c.s: Likewise.
+
2017-05-16 H.J. Lu <hongjiu.lu@intel.com>
PR ld/21481
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index ba4f70b..ba5c46b 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -104,6 +104,7 @@ run_dump_test "start"
run_dump_test "pr19167"
if { [is_elf_format] } then {
run_dump_test "all-debug-sections"
+ run_dump_test "pr20882"
}
if { [is_elf_format] && [check_shared_lib_support] } then {
diff --git a/ld/testsuite/ld-gc/pr20882.d b/ld/testsuite/ld-gc/pr20882.d
new file mode 100644
index 0000000..55fa141
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr20882.d
@@ -0,0 +1,10 @@
+#name: --gc-sections with relocations in debug section
+#source: pr20882a.s
+#source: pr20882b.s
+#source: pr20882c.s
+#as: -gdwarf-sections
+#ld: --gc-sections -e main
+#readelf: -x .debug_info
+
+#...
+ +0x0+ [0-9a-f ]+ 28 +.+\(
diff --git a/ld/testsuite/ld-gc/pr20882a.s b/ld/testsuite/ld-gc/pr20882a.s
new file mode 100644
index 0000000..3348ba9
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr20882a.s
@@ -0,0 +1,11 @@
+ .text
+ .globl main
+ .type main, %function
+main:
+ .byte 0
+
+ .section .debug_info,"",%progbits
+ .dc.a t.c.4903c230+2
+
+ .section .debug_line,"",%progbits
+ .byte 0
diff --git a/ld/testsuite/ld-gc/pr20882b.s b/ld/testsuite/ld-gc/pr20882b.s
new file mode 100644
index 0000000..fed521c
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr20882b.s
@@ -0,0 +1,8 @@
+ .section .debug_info,"",%progbits
+ .hidden t.c.4903c230
+ .globl t.c.4903c230
+t.c.4903c230:
+ .byte 0x28
+
+ .section .debug_line,"",%progbits
+ .byte 0
diff --git a/ld/testsuite/ld-gc/pr20882c.s b/ld/testsuite/ld-gc/pr20882c.s
new file mode 100644
index 0000000..a77edad
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr20882c.s
@@ -0,0 +1,8 @@
+ .section .debug_info,"",%progbits
+ .hidden t.c.4903c231
+ .globl t.c.4903c231
+t.c.4903c231:
+ .byte 0x29
+
+ .section .debug_line,"",%progbits
+ .byte 0