PR28029, debuginfod tests

binutils/NEWS says of the change in --process-links semantics:
  If other debug section display options are also enabled (eg
  --debug-dump=info) then the contents of matching sections in both the main
  file and the separate debuginfo file *will* be displayed.  This is because in
  most cases the debug section will only be present in one of the files.

Implying that debug info is dumped without --process-links.  Indeed
that appears to be the case for readelf.  This does the same for
objdump.

	PR 28029
	* objdump.c (dump_bfd): Do not exit early when !is_mainfile
	&& !processlinks, instead just exclude non-debug output.
	(dump_dwarf): Add is_mainfile parameter and pass to
	dump_dwarf_section.
	(dump_dwarf_section): Only display debug sections when
	!is_mainfile and !process_links.
This commit is contained in:
Alan Modra
2021-11-22 10:16:01 +10:30
parent 48e3e6aec8
commit e2c0149e8b

View File

@@ -3942,15 +3942,20 @@ get_build_id (void * data)
static void static void
dump_dwarf_section (bfd *abfd, asection *section, dump_dwarf_section (bfd *abfd, asection *section,
void *arg ATTRIBUTE_UNUSED) void *arg)
{ {
const char *name = bfd_section_name (section); const char *name = bfd_section_name (section);
const char *match; const char *match;
int i; int i;
bool is_mainfile = *(bool *) arg;
if (*name == 0) if (*name == 0)
return; return;
if (!is_mainfile && !process_links
&& (section->flags & SEC_DEBUGGING) == 0)
return;
if (startswith (name, ".gnu.linkonce.wi.")) if (startswith (name, ".gnu.linkonce.wi."))
match = ".debug_info"; match = ".debug_info";
else else
@@ -3986,7 +3991,7 @@ dump_dwarf_section (bfd *abfd, asection *section,
/* Dump the dwarf debugging information. */ /* Dump the dwarf debugging information. */
static void static void
dump_dwarf (bfd *abfd) dump_dwarf (bfd *abfd, bool is_mainfile)
{ {
/* The byte_get pointer should have been set at the start of dump_bfd(). */ /* The byte_get pointer should have been set at the start of dump_bfd(). */
if (byte_get == NULL) if (byte_get == NULL)
@@ -4012,7 +4017,7 @@ dump_dwarf (bfd *abfd)
init_dwarf_regnames_by_bfd_arch_and_mach (bfd_get_arch (abfd), init_dwarf_regnames_by_bfd_arch_and_mach (bfd_get_arch (abfd),
bfd_get_mach (abfd)); bfd_get_mach (abfd));
bfd_map_over_sections (abfd, dump_dwarf_section, NULL); bfd_map_over_sections (abfd, dump_dwarf_section, (void *) &is_mainfile);
} }
/* Read ABFD's stabs section STABSECT_NAME, and return a pointer to /* Read ABFD's stabs section STABSECT_NAME, and return a pointer to
@@ -5053,9 +5058,8 @@ dump_bfd (bfd *abfd, bool is_mainfile)
bfd_map_over_sections (abfd, adjust_addresses, &has_reloc); bfd_map_over_sections (abfd, adjust_addresses, &has_reloc);
} }
if (! is_mainfile && ! process_links) if (is_mainfile || process_links)
return; {
if (! dump_debugging_tags && ! suppress_bfd_header) if (! dump_debugging_tags && ! suppress_bfd_header)
printf (_("\n%s: file format %s\n"), printf (_("\n%s: file format %s\n"),
sanitize_string (bfd_get_filename (abfd)), sanitize_string (bfd_get_filename (abfd)),
@@ -5070,6 +5074,7 @@ dump_bfd (bfd *abfd, bool is_mainfile)
dump_target_specific (abfd); dump_target_specific (abfd);
if (! dump_debugging_tags && ! suppress_bfd_header) if (! dump_debugging_tags && ! suppress_bfd_header)
putchar ('\n'); putchar ('\n');
}
if (dump_symtab if (dump_symtab
|| dump_reloc_info || dump_reloc_info
@@ -5112,6 +5117,8 @@ dump_bfd (bfd *abfd, bool is_mainfile)
} }
} }
if (is_mainfile || process_links)
{
if (dump_section_headers) if (dump_section_headers)
dump_headers (abfd); dump_headers (abfd);
@@ -5122,7 +5129,8 @@ dump_bfd (bfd *abfd, bool is_mainfile)
if (disassemble) if (disassemble)
{ {
synthcount = bfd_get_synthetic_symtab (abfd, symcount, syms, synthcount = bfd_get_synthetic_symtab (abfd, symcount, syms,
dynsymcount, dynsyms, &synthsyms); dynsymcount, dynsyms,
&synthsyms);
if (synthcount < 0) if (synthcount < 0)
synthcount = 0; synthcount = 0;
} }
@@ -5131,8 +5139,11 @@ dump_bfd (bfd *abfd, bool is_mainfile)
dump_symbols (abfd, false); dump_symbols (abfd, false);
if (dump_dynamic_symtab) if (dump_dynamic_symtab)
dump_symbols (abfd, true); dump_symbols (abfd, true);
}
if (dump_dwarf_section_info) if (dump_dwarf_section_info)
dump_dwarf (abfd); dump_dwarf (abfd, is_mainfile);
if (is_mainfile || process_links)
{
if (dump_ctf_section_info) if (dump_ctf_section_info)
dump_ctf (abfd, dump_ctf_section_name, dump_ctf_parent_name); dump_ctf (abfd, dump_ctf_section_name, dump_ctf_parent_name);
if (dump_stab_section_info) if (dump_stab_section_info)
@@ -5145,6 +5156,7 @@ dump_bfd (bfd *abfd, bool is_mainfile)
dump_data (abfd); dump_data (abfd);
if (disassemble) if (disassemble)
disassemble_data (abfd); disassemble_data (abfd);
}
if (dump_debugging) if (dump_debugging)
{ {
@@ -5169,7 +5181,7 @@ dump_bfd (bfd *abfd, bool is_mainfile)
else if (! dump_dwarf_section_info) else if (! dump_dwarf_section_info)
{ {
dwarf_select_sections_all (); dwarf_select_sections_all ();
dump_dwarf (abfd); dump_dwarf (abfd, is_mainfile);
} }
} }