This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Garbage collecting debug sections
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 25 Mar 2015 10:12:41 -0000
- Subject: [binutils-gdb] Garbage collecting debug sections
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d422d1c433073ba412287334a7ec3aa95e03c5e9
commit d422d1c433073ba412287334a7ec3aa95e03c5e9
Author: Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
Date: Tue Mar 24 19:18:04 2015 +0530
Garbage collecting debug sections
I noticed that _bfd_elf_gc_mark_extra_sections attempts to unmark
related debug sections when it finds an unmarked code section.
When it finds .text.foo is unmarked, for example, it removes
.debug_line.text.foo as well (using the section name as a suffix
match check.
However, it bails out after finding one such section.
bfd/
* elflink.c (_bfd_elf_gc_mark_extra_sections): Don't break on
first matching debug section.
ld/testsuite/
* ld-gc/all-debug-sections.d: New file.
* ld-gc/all-debug-sections.s: Likewise.
* ld-gc/gc.exp: Execute new testcase.
Diff:
---
bfd/ChangeLog | 5 +++
bfd/elflink.c | 1 -
ld/testsuite/ChangeLog | 6 ++++
ld/testsuite/ld-gc/all-debug-sections.d | 10 ++++++
ld/testsuite/ld-gc/all-debug-sections.s | 56 +++++++++++++++++++++++++++++++++
ld/testsuite/ld-gc/gc.exp | 3 ++
6 files changed, 80 insertions(+), 1 deletion(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 469066b..78895be 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-25 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
+
+ * elflink.c (_bfd_elf_gc_mark_extra_sections): Don't break on
+ first matching debug section.
+
2015-03-24 H.J. Lu <hongjiu.lu@intel.com>
PR gas/18087
diff --git a/bfd/elflink.c b/bfd/elflink.c
index f93293b..9ccad8c 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -12102,7 +12102,6 @@ _bfd_elf_gc_mark_extra_sections (struct bfd_link_info *info,
isec->name, ilen) == 0)
{
dsec->gc_mark = 0;
- break;
}
}
}
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 6e13e9c..8eef67e 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-25 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
+
+ * ld-gc/all-debug-sections.d: New file.
+ * ld-gc/all-debug-sections.s: Likewise.
+ * ld-gc/gc.exp: Execute new testcase.
+
2015-03-11 Alan Modra <amodra@gmail.com>
* ld-powerpc/tls32.s: Add GOT pointer setup.
diff --git a/ld/testsuite/ld-gc/all-debug-sections.d b/ld/testsuite/ld-gc/all-debug-sections.d
new file mode 100644
index 0000000..5e3373a
--- /dev/null
+++ b/ld/testsuite/ld-gc/all-debug-sections.d
@@ -0,0 +1,10 @@
+#name: --gc-sections with multiple debug sections for a function section
+#as: -gdwarf-sections
+#ld: --gc-sections -e _start
+#PROG: nm
+
+#...
+[0-9a-f]+ N +debug_aranges_main
+[0-9a-f]+ N +debug_info_main
+[0-9a-f]+ N +debug_line_main
+#...
diff --git a/ld/testsuite/ld-gc/all-debug-sections.s b/ld/testsuite/ld-gc/all-debug-sections.s
new file mode 100644
index 0000000..076f183
--- /dev/null
+++ b/ld/testsuite/ld-gc/all-debug-sections.s
@@ -0,0 +1,56 @@
+ .section .text.useless,"ax",%progbits
+ .globl useless
+ .type useless, %function
+useless:
+ .long 1
+
+ .section .text.main,"ax",%progbits
+ .globl _start
+_start:
+ .globl main
+ .type main, %function
+main:
+ .long 2
+
+ .section .text,"ax",%progbits
+ .long main
+
+ .section .debug_info.text.main,"",%progbits
+debug_info_main:
+ .long 0x3c
+ .long main
+
+ .section .debug_info.text.useless,"",%progbits
+debug_info_useless:
+ .long 0x38
+ .long useless
+
+ .section .debug_info,"",%progbits
+ .long 0x49
+
+ .section .debug_aranges,"",%progbits
+ .long 0x3c
+
+ .section .debug_aranges.text.main,"",%progbits
+debug_aranges_main:
+ .long 0x2c
+ .long main
+
+ .section .debug_aranges.text.useless,"",%progbits
+debug_aranges_useless:
+ .long 0x2c
+ .long useless
+
+ .section .debug_line,"",%progbits
+ .long 0x3c
+
+ .section .debug_line.text.main,"",%progbits
+debug_line_main:
+ .long 0x2c
+ .long main
+
+ .section .debug_line.text.useless,"",%progbits
+debug_line_useless:
+ .long 0x2c
+ .long useless
+
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index 5ff6485..58f3a2a 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -101,6 +101,9 @@ test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func"
run_dump_test "noent"
run_dump_test "abi-note"
run_dump_test "start"
+if { [is_elf_format] } then {
+ run_dump_test "all-debug-sections"
+}
if { [is_elf_format] && [check_shared_lib_support] } then {
set gasopt ""