summaryrefslogtreecommitdiff
path: root/binutils/readelf.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-11-21 13:12:04 +0000
committerNick Clifton <nickc@redhat.com>2017-11-21 13:12:04 +0000
commitd85bf2ba86fea1cf918f065d179b98eb4ddbde86 (patch)
treeb63b374b40e58403431a94352c421751d85127e9 /binutils/readelf.c
parent0fc7642151cc5e62f05ac8ea91fe4d5b44bee11a (diff)
Add ability to follow dwo links to readelf/objdump.
* dwarf.c (dwo_name, dwo_dir, dwo_id, dwo_id_len): New variables. (read_and_display_attr_value): Record dwo variables if requested. (display_augmentation_data): Rename to display_data and make generic. (load_dwo_file): New function. Loads a separate dwarf object file. (load_separate_debug_file): Add reporting and loading of separate dwarf objet files. * readelf.c (process_section_headers): Add do_debug_links to list of flags requiring a debug dump. (display_debug_section): Tidy up code. * doc/debug.options.texi: Add note that dwo links will also be followed. * testsuite/binutils-all/debuglink.s: Tidy code. * testsuite/binutils-all/dwo.s: New test file. * testsuite/binutils-all/readelf.wk2: New file - expected output from readelf. * testsuite/binutils-all/readelf.exp: Run the new test.
Diffstat (limited to 'binutils/readelf.c')
-rw-r--r--binutils/readelf.c59
1 files changed, 31 insertions, 28 deletions
diff --git a/binutils/readelf.c b/binutils/readelf.c
index a372620c66..ea7cc3e18e 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -6084,7 +6084,7 @@ process_section_headers (Filedata * filedata)
|| do_debug_lines || do_debug_pubnames || do_debug_pubtypes
|| do_debug_aranges || do_debug_frames || do_debug_macinfo
|| do_debug_str || do_debug_loc || do_debug_ranges
- || do_debug_addr || do_debug_cu_index)
+ || do_debug_addr || do_debug_cu_index || do_debug_links)
&& (const_strneq (name, ".debug_")
|| const_strneq (name, ".zdebug_")))
{
@@ -13658,40 +13658,43 @@ display_debug_section (int shndx, Elf_Internal_Shdr * section, Filedata * fileda
/* See if we know how to display the contents of this section. */
for (i = 0; i < max; i++)
- if (streq (debug_displays[i].section.uncompressed_name, name)
- || (i == line && const_strneq (name, ".debug_line."))
- || streq (debug_displays[i].section.compressed_name, name))
- {
- struct dwarf_section * sec = &debug_displays [i].section;
- int secondary = (section != find_section (filedata, name));
+ {
+ enum dwarf_section_display_enum id = (enum dwarf_section_display_enum) i;
+ struct dwarf_section_display * display = debug_displays + i;
+ struct dwarf_section * sec = & display->section;
- if (secondary)
- free_debug_section ((enum dwarf_section_display_enum) i);
+ if (streq (sec->uncompressed_name, name)
+ || (id == line && const_strneq (name, ".debug_line."))
+ || streq (sec->compressed_name, name))
+ {
+ bfd_boolean secondary = (section != find_section (filedata, name));
- if (i == line && const_strneq (name, ".debug_line."))
- sec->name = name;
- else if (streq (sec->uncompressed_name, name))
- sec->name = sec->uncompressed_name;
- else
- sec->name = sec->compressed_name;
+ if (secondary)
+ free_debug_section (id);
- if (load_specific_debug_section ((enum dwarf_section_display_enum) i,
- section, filedata))
- {
- /* If this debug section is part of a CU/TU set in a .dwp file,
- restrict load_debug_section to the sections in that set. */
- section_subset = find_cu_tu_set (filedata, shndx);
+ if (i == line && const_strneq (name, ".debug_line."))
+ sec->name = name;
+ else if (streq (sec->uncompressed_name, name))
+ sec->name = sec->uncompressed_name;
+ else
+ sec->name = sec->compressed_name;
- result &= debug_displays[i].display (sec, filedata);
+ if (load_specific_debug_section (id, section, filedata))
+ {
+ /* If this debug section is part of a CU/TU set in a .dwp file,
+ restrict load_debug_section to the sections in that set. */
+ section_subset = find_cu_tu_set (filedata, shndx);
- section_subset = NULL;
+ result &= display->display (sec, filedata);
- if (secondary || (i != info && i != abbrev))
- free_debug_section ((enum dwarf_section_display_enum) i);
- }
+ section_subset = NULL;
- break;
- }
+ if (secondary || (id != info && id != abbrev))
+ free_debug_section (id);
+ }
+ break;
+ }
+ }
if (i == max)
{