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