This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb/binutils-2_30-branch] GC: Also check the local debug definition section
- From: H.J.Lu <hjl at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 14 Mar 2018 12:21:56 -0000
- Subject: [binutils-gdb/binutils-2_30-branch] GC: Also check the local debug definition section
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=da8c5cfcc9fa7fc77878ce177d1b52348ae52f26
commit da8c5cfcc9fa7fc77878ce177d1b52348ae52f26
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Mar 14 04:23:24 2018 -0700
GC: Also check the local debug definition section
Extend
commit b7c871edcd83ccdc5fcd8148a7f433efd6b52255
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed May 17 07:57:15 2017 -0700
Mark debug sections referenced by kept debug sections
to handle the local debug definition section.
bfd/
PR ld/20882
* elflink.c (elf_gc_mark_debug_section): Also check the local
debug definition section.
ld/
PR ld/20882
* testsuite/ld-gc/pr20882.d: Also dump and check .debug_abbrev
section.
* testsuite/ld-gc/pr20882b.s: Add .debug_abbrev section.
(cherry picked from commit 9e223787a474c672c5f1cfd4574857241ae4eafa)
Diff:
---
bfd/ChangeLog | 6 ++++++
bfd/elflink.c | 25 ++++++++++++++++++-------
ld/ChangeLog | 7 +++++++
ld/testsuite/ld-gc/pr20882.d | 9 ++++++---
ld/testsuite/ld-gc/pr20882b.s | 9 ++++++++-
5 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index de354fc..6d1a967 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2018-03-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/20882
+ * elflink.c (elf_gc_mark_debug_section): Also check the local
+ debug definition section.
+
2018-02-28 Jim Wilson <jimw@sifive.com>
Import patch from mainline:
diff --git a/bfd/elflink.c b/bfd/elflink.c
index e3751fa..72aa3ac 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -12785,20 +12785,31 @@ _bfd_elf_gc_mark_hook (asection *sec,
return NULL;
}
-/* Return the global debug definition section. */
+/* Return the debug definition section. */
static asection *
elf_gc_mark_debug_section (asection *sec ATTRIBUTE_UNUSED,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
Elf_Internal_Rela *rel ATTRIBUTE_UNUSED,
struct elf_link_hash_entry *h,
- Elf_Internal_Sym *sym ATTRIBUTE_UNUSED)
+ Elf_Internal_Sym *sym)
{
- if (h != NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- && (h->root.u.def.section->flags & SEC_DEBUGGING) != 0)
- return h->root.u.def.section;
+ if (h != NULL)
+ {
+ /* Return the global debug definition section. */
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && (h->root.u.def.section->flags & SEC_DEBUGGING) != 0)
+ return h->root.u.def.section;
+ }
+ else
+ {
+ /* Return the local debug definition section. */
+ asection *isec = bfd_section_from_elf_index (sec->owner,
+ sym->st_shndx);
+ if ((isec->flags & SEC_DEBUGGING) != 0)
+ return isec;
+ }
return NULL;
}
diff --git a/ld/ChangeLog b/ld/ChangeLog
index a4b3639..b5cf58a 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2018-03-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/20882
+ * testsuite/ld-gc/pr20882.d: Also dump and check .debug_abbrev
+ section.
+ * testsuite/ld-gc/pr20882b.s: Add .debug_abbrev section.
+
2018-02-09 Eric Botcazou <ebotcazou@adacore.com>
* testsuite/ld-elf/pr22450.d: Remove reference to SPARC64.
diff --git a/ld/testsuite/ld-gc/pr20882.d b/ld/testsuite/ld-gc/pr20882.d
index dd388c5..1d68d05 100644
--- a/ld/testsuite/ld-gc/pr20882.d
+++ b/ld/testsuite/ld-gc/pr20882.d
@@ -3,7 +3,10 @@
#source: pr20882b.s
#source: pr20882c.s
#ld: --gc-sections -e main
-#readelf: -x .debug_info
+#readelf: -x .debug_info -x .debug_abbrev
-#...
- 0x0+ (0a000000 00000000 |00000000 0000000a |06000000 |00000006 |0400|0004)28 .*
+Hex dump of section '\.debug_info':
+ 0x0+ .*
+
+Hex dump of section '\.debug_abbrev':
+ 0x0+ 61626364 +abcd
diff --git a/ld/testsuite/ld-gc/pr20882b.s b/ld/testsuite/ld-gc/pr20882b.s
index ea0cf2e..baabf55 100644
--- a/ld/testsuite/ld-gc/pr20882b.s
+++ b/ld/testsuite/ld-gc/pr20882b.s
@@ -2,4 +2,11 @@
.hidden t.c.4903c230
.globl t.c.4903c230
t.c.4903c230:
- .byte 0x28
+ .dc.a .Ldebug_abbrev0
+
+ .section .debug_abbrev,"",%progbits
+.Ldebug_abbrev0:
+ .byte 0x61
+ .byte 0x62
+ .byte 0x63
+ .byte 0x64