Extend readelf and objdump so that they will display and follow multiple links to separate debug information files.

PR 23843
	* dwarf.h (struct separate_info): New structure for containing
	information on separate debug info files.
	* dwarf.c (struct dwo_info): New structure for containing dwo
	links.
	(first_dwo_info): Chain of dwo_info structures.
	(first_separate_file): Chain of separate_info structures.
	(separate_debug_file, separate_debug_filename): Delete.
	(fetch_alt_indirect_string): Scan all separate debug info files
	for the requested string.
	(add_dwo_info): New function.
	(add_dwo_name): New function.
	(add_dwo_dir): New function.
	(add_dwo_id: New function.
	(free_dwo_info): New function.
	(read_and_display_attr_value): Store DWO data using the new
	functions.
	(load_debug_section_with_follow): If necessary, scan the list of
	separate debug info files for the requested section.
	(add_separate_debug_file): New function.
	(load_separate_debug_info): Call add_separate_debug_file to store
	the information on the newly loaded file.
	(load_dwo_file): Likewise.
	(load_separate_debif_file): Rename to load_separate_debug_files.
	Change return type to boolean.  If following links then attempt to
	load all separate debug info files, not just the first one.
	(free_debug_memory): Release memory in dwo_info and separate_info
	chains.
	* objdump.c (dump_dwarf): Iterate over all loaded debg info files.
	* readelf.c (process_object): Likewise.
	* doc/debug.options.texi: Update descriptions of links and
	follow-links options.
	* testsuite/binutils-all/objdump.WK2: Update expected output.
	* testsuite/binutils-all/readelf.k2: Likewise.
	* NEWS: Announce the new feature.
This commit is contained in:
Nick Clifton 2019-02-22 10:36:24 +00:00
parent 83f43c8344
commit 24841daa74
9 changed files with 381 additions and 187 deletions

View file

@ -19302,7 +19302,7 @@ open_debug_file (const char * pathname)
static bfd_boolean
process_object (Filedata * filedata)
{
Filedata * separates;
bfd_boolean have_separate_files;
unsigned int i;
bfd_boolean res = TRUE;
@ -19379,19 +19379,26 @@ process_object (Filedata * filedata)
res = FALSE;
if (filedata->file_header.e_shstrndx != SHN_UNDEF)
separates = load_separate_debug_file (filedata, filedata->file_name);
have_separate_files = load_separate_debug_files (filedata, filedata->file_name);
else
separates = NULL;
have_separate_files = FALSE;
if (! process_section_contents (filedata))
res = FALSE;
if (separates)
if (have_separate_files)
{
if (! process_section_headers (separates))
res = FALSE;
else if (! process_section_contents (separates))
res = FALSE;
separate_info * d;
for (d = first_separate_info; d != NULL; d = d->next)
{
if (! process_section_headers (d->handle))
res = FALSE;
else if (! process_section_contents (d->handle))
res = FALSE;
}
/* The file handles are closed by the call to free_debug_memory() below. */
}
if (! process_notes (filedata))