]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix the debuglink following code to recursively load links found in the newly loaded...
authorNick Clifton <nickc@redhat.com>
Fri, 11 Sep 2020 12:30:38 +0000 (13:30 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 11 Sep 2020 12:30:56 +0000 (13:30 +0100)
PR 26595
* dwarf.c (load_separate_debug_info): Return NULL rather than
FALSE in error situations.
(load_separate_debug_file): Move code to load debug links to ...
(check_for_and_load_links): ... here.  New function.  Load
separate debug information pointed to by debuglink and
debugaltlink sections.  Recursively scan newly loaded debug
information for more links and load them too.

binutils/ChangeLog
binutils/dwarf.c

index 89860a0406c17b072b7a46d0622f7ea3297a5f4c..a925dbbbcd58bce9964286e894d675f577a022b2 100644 (file)
@@ -1,3 +1,14 @@
+2020-09-11  Nick Clifton  <nickc@redhat.com>
+
+       PR 26595
+       * dwarf.c (load_separate_debug_info): Return NULL rather than
+       FALSE in error situations.
+       (load_separate_debug_file): Move code to load debug links to ...
+       (check_for_and_load_links): ... here.  New function.  Load
+       separate debug information pointed to by debuglink and
+       debugaltlink sections.  Recursively scan newly loaded debug
+       information for more links and load them too.
+
 2020-09-09  Alan Modra  <amodra@gmail.com>
 
        PR 26578
index 9c141b1776224106ba7e287d937b755caa609069..603169226d4d53880c7226740f5d45d53a1213b7 100644 (file)
@@ -10459,7 +10459,7 @@ load_separate_debug_info (const char *            main_filename,
     {
       warn (_("Corrupt debuglink section: %s\n"),
            xlink->name ? xlink->name : xlink->uncompressed_name);
-      return FALSE;
+      return NULL;
     }
     
   /* Attempt to locate the separate file.
@@ -10619,7 +10619,7 @@ load_separate_debug_info (const char *            main_filename,
     {
       warn (_("failed to open separate debug file: %s\n"), debug_filename);
       free (debug_filename);
-      return FALSE;
+      return NULL;
     }
 
   /* FIXME: We do not check to see if there are any other separate debug info
@@ -10664,6 +10664,52 @@ load_dwo_file (const char * main_filename, const char * name, const char * dir,
   return separate_handle;
 }
 
+/* Load a debuglink section and/or a debugaltlink section, if either are present.
+   Recursively check the loaded files for more of these sections.
+   FIXME: Should also check for DWO_* entries in the newlu loaded files.  */
+
+static void
+check_for_and_load_links (void * file, const char * filename)
+{
+  void * handle = NULL;
+
+  if (load_debug_section (gnu_debugaltlink, file))
+    {
+      Build_id_data build_id_data;
+
+      handle = load_separate_debug_info (filename,
+                                        & debug_displays[gnu_debugaltlink].section,
+                                        parse_gnu_debugaltlink,
+                                        check_gnu_debugaltlink,
+                                        & build_id_data,
+                                        file);
+      if (handle)
+       {
+         assert (handle == first_separate_info->handle);
+         check_for_and_load_links (first_separate_info->handle,
+                                   first_separate_info->filename);
+       }
+    }
+
+  if (load_debug_section (gnu_debuglink, file))
+    {
+      unsigned long crc32;
+
+      handle = load_separate_debug_info (filename,
+                                        & debug_displays[gnu_debuglink].section,
+                                        parse_gnu_debuglink,
+                                        check_gnu_debuglink,
+                                        & crc32,
+                                        file);
+      if (handle)
+       {
+         assert (handle == first_separate_info->handle);
+         check_for_and_load_links (first_separate_info->handle,
+                                   first_separate_info->filename);
+       }
+    }
+}
+
 /* Load the separate debug info file(s) attached to FILE, if any exist.
    Returns TRUE if any were found, FALSE otherwise.
    If TRUE is returned then the linked list starting at first_separate_info
@@ -10739,34 +10785,10 @@ load_separate_debug_files (void * file, const char * filename)
     return FALSE;
 
   /* FIXME: We do not check for the presence of both link sections in the same file.  */
-  /* FIXME: We do not check the separate debug info file to see if it too contains debuglinks.  */
   /* FIXME: We do not check for the presence of multiple, same-name debuglink sections.  */
   /* FIXME: We do not check for the presence of a dwo link as well as a debuglink.  */
 
-  if (load_debug_section (gnu_debugaltlink, file))
-    {
-      Build_id_data build_id_data;
-
-      load_separate_debug_info (filename,
-                               & debug_displays[gnu_debugaltlink].section,
-                               parse_gnu_debugaltlink,
-                               check_gnu_debugaltlink,
-                               & build_id_data,
-                               file);
-    }
-
-  if (load_debug_section (gnu_debuglink, file))
-    {
-      unsigned long crc32;
-
-      load_separate_debug_info (filename,
-                               & debug_displays[gnu_debuglink].section,
-                               parse_gnu_debuglink,
-                               check_gnu_debuglink,
-                               & crc32,
-                               file);
-    }
-
+  check_for_and_load_links (file, filename);
   if (first_separate_info != NULL)
     return TRUE;