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

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