From: Nick Clifton Date: Fri, 11 Sep 2020 12:30:38 +0000 (+0100) Subject: Fix the debuglink following code to recursively load links found in the newly loaded... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ce139cd560dcb85b09d4d257ac67ebffdf215859;p=binutils-gdb.git Fix the debuglink following code to recursively load links found in the newly loaded debug info. 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. --- diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 89860a0406c..a925dbbbcd5 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,14 @@ +2020-09-11 Nick Clifton + + 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 PR 26578 diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 9c141b17762..603169226d4 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -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;