This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] GC: Also check the local debug definition section
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Cc: Nick Clifton <nickc at redhat dot com>
- Date: Tue, 13 Mar 2018 10:30:14 -0700
- Subject: [PATCH] GC: Also check the local debug definition section
- Authentication-results: sourceware.org; auth=none
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
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.
OK for master?
H.J.
PR ld/20882
* elflink.c (elf_gc_mark_debug_section): Also check the local
debug definition section.
---
bfd/elflink.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 092edaea26..6a3d516ba8 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -12802,20 +12802,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;
}
--
2.14.3