diff options
author | Nick Clifton <nickc@redhat.com> | 2020-09-11 13:30:38 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2020-09-11 13:30:56 +0100 |
commit | ce139cd560dcb85b09d4d257ac67ebffdf215859 (patch) | |
tree | cdb96ee32f9db63b845bc3fcd5ef5daba6c46b23 /binutils | |
parent | 7a4e8e7d551eaddc63c67d85c02c7573f5a56ae8 (diff) | |
download | gdb-ce139cd560dcb85b09d4d257ac67ebffdf215859.zip gdb-ce139cd560dcb85b09d4d257ac67ebffdf215859.tar.gz gdb-ce139cd560dcb85b09d4d257ac67ebffdf215859.tar.bz2 |
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.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 11 | ||||
-rw-r--r-- | binutils/dwarf.c | 76 |
2 files changed, 60 insertions, 27 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 89860a0..a925dbb 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -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 diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 9c141b1..6031692 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; |