Blame SOURCES/binutils-debug-section-marking.patch

381f6c
--- binutils.orig/bfd/elflink.c	2018-03-14 10:14:49.729271271 +0000
381f6c
+++ binutils-2.30/bfd/elflink.c	2018-03-14 10:15:15.748967793 +0000
381f6c
@@ -12785,7 +12785,7 @@ _bfd_elf_gc_mark_hook (asection *sec,
381f6c
   return NULL;
381f6c
 }
381f6c
 
381f6c
-/* Return the global debug definition section.  */
381f6c
+/* Return the debug definition section.  */
381f6c
 
381f6c
 static asection *
381f6c
 elf_gc_mark_debug_section (asection *sec ATTRIBUTE_UNUSED,
381f6c
@@ -12794,11 +12794,22 @@ elf_gc_mark_debug_section (asection *sec
381f6c
 			   struct elf_link_hash_entry *h,
381f6c
 			   Elf_Internal_Sym *sym ATTRIBUTE_UNUSED)
381f6c
 {
381f6c
-  if (h != NULL
381f6c
-      && (h->root.type == bfd_link_hash_defined
381f6c
-	  || h->root.type == bfd_link_hash_defweak)
381f6c
-      && (h->root.u.def.section->flags & SEC_DEBUGGING) != 0)
381f6c
-    return h->root.u.def.section;
381f6c
+  if (h != NULL)
381f6c
+    {
381f6c
+      /* Return the global debug definition section.  */
381f6c
+      if ((h->root.type == bfd_link_hash_defined
381f6c
+	   || h->root.type == bfd_link_hash_defweak)
381f6c
+	  && (h->root.u.def.section->flags & SEC_DEBUGGING) != 0)
381f6c
+	return h->root.u.def.section;
381f6c
+    }
381f6c
+  else
381f6c
+    {
381f6c
+      /* Return the local debug definition section.  */
381f6c
+      asection *isec = bfd_section_from_elf_index (sec->owner,
381f6c
+						   sym->st_shndx);
381f6c
+      if ((isec->flags & SEC_DEBUGGING) != 0)
381f6c
+	return isec;
381f6c
+    }
381f6c
 
381f6c
   return NULL;
381f6c
 }