Blame SOURCES/binutils-recursive-debuglink-following.patch

d1152b
--- binutils.orig/binutils/dwarf.c	2020-10-15 12:13:21.960799738 +0100
d1152b
+++ binutils-2.35.1/binutils/dwarf.c	2020-10-15 13:02:39.454692627 +0100
d1152b
@@ -10427,7 +10427,7 @@ load_separate_debug_info (const char *
d1152b
     {
d1152b
       warn (_("Corrupt debuglink section: %s\n"),
d1152b
 	    xlink->name ? xlink->name : xlink->uncompressed_name);
d1152b
-      return FALSE;
d1152b
+      return NULL;
d1152b
     }
d1152b
     
d1152b
   /* Attempt to locate the separate file.
d1152b
@@ -10587,7 +10587,7 @@ load_separate_debug_info (const char *
d1152b
     {
d1152b
       warn (_("failed to open separate debug file: %s\n"), debug_filename);
d1152b
       free (debug_filename);
d1152b
-      return FALSE;
d1152b
+      return NULL;
d1152b
     }
d1152b
 
d1152b
   /* FIXME: We do not check to see if there are any other separate debug info
d1152b
@@ -10632,6 +10632,52 @@ load_dwo_file (const char * main_filenam
d1152b
   return separate_handle;
d1152b
 }
d1152b
 
d1152b
+/* Load a debuglink section and/or a debugaltlink section, if either are present.
d1152b
+   Recursively check the loaded files for more of these sections.
d1152b
+   FIXME: Should also check for DWO_* entries in the newlu loaded files.  */
d1152b
+
d1152b
+static void
d1152b
+check_for_and_load_links (void * file, const char * filename)
d1152b
+{
d1152b
+  void * handle = NULL;
d1152b
+
d1152b
+  if (load_debug_section (gnu_debugaltlink, file))
d1152b
+    {
d1152b
+      Build_id_data build_id_data;
d1152b
+
d1152b
+      handle = load_separate_debug_info (filename,
d1152b
+					 & debug_displays[gnu_debugaltlink].section,
d1152b
+					 parse_gnu_debugaltlink,
d1152b
+					 check_gnu_debugaltlink,
d1152b
+					 & build_id_data,
d1152b
+					 file);
d1152b
+      if (handle)
d1152b
+	{
d1152b
+	  assert (handle == first_separate_info->handle);
d1152b
+	  check_for_and_load_links (first_separate_info->handle,
d1152b
+				    first_separate_info->filename);
d1152b
+	}
d1152b
+    }
d1152b
+
d1152b
+  if (load_debug_section (gnu_debuglink, file))
d1152b
+    {
d1152b
+      unsigned long crc32;
d1152b
+
d1152b
+      handle = load_separate_debug_info (filename,
d1152b
+					 & debug_displays[gnu_debuglink].section,
d1152b
+					 parse_gnu_debuglink,
d1152b
+					 check_gnu_debuglink,
d1152b
+					 & crc32,
d1152b
+					 file);
d1152b
+      if (handle)
d1152b
+	{
d1152b
+	  assert (handle == first_separate_info->handle);
d1152b
+	  check_for_and_load_links (first_separate_info->handle,
d1152b
+				    first_separate_info->filename);
d1152b
+	}
d1152b
+    }
d1152b
+}
d1152b
+
d1152b
 /* Load the separate debug info file(s) attached to FILE, if any exist.
d1152b
    Returns TRUE if any were found, FALSE otherwise.
d1152b
    If TRUE is returned then the linked list starting at first_separate_info
d1152b
@@ -10707,34 +10753,10 @@ load_separate_debug_files (void * file,
d1152b
     return FALSE;
d1152b
 
d1152b
   /* FIXME: We do not check for the presence of both link sections in the same file.  */
d1152b
-  /* FIXME: We do not check the separate debug info file to see if it too contains debuglinks.  */
d1152b
   /* FIXME: We do not check for the presence of multiple, same-name debuglink sections.  */
d1152b
   /* FIXME: We do not check for the presence of a dwo link as well as a debuglink.  */
d1152b
 
d1152b
-  if (load_debug_section (gnu_debugaltlink, file))
d1152b
-    {
d1152b
-      Build_id_data * build_id_data;
d1152b
-
d1152b
-      load_separate_debug_info (filename,
d1152b
-				& debug_displays[gnu_debugaltlink].section,
d1152b
-				parse_gnu_debugaltlink,
d1152b
-				check_gnu_debugaltlink,
d1152b
-				& build_id_data,
d1152b
-				file);
d1152b
-    }
d1152b
-
d1152b
-  if (load_debug_section (gnu_debuglink, file))
d1152b
-    {
d1152b
-      unsigned long crc32;
d1152b
-
d1152b
-      load_separate_debug_info (filename,
d1152b
-				& debug_displays[gnu_debuglink].section,
d1152b
-				parse_gnu_debuglink,
d1152b
-				check_gnu_debuglink,
d1152b
-				& crc32,
d1152b
-				file);
d1152b
-    }
d1152b
-
d1152b
+  check_for_and_load_links (file, filename);
d1152b
   if (first_separate_info != NULL)
d1152b
     return TRUE;
d1152b