PR28029, debuginfod tests

Alan Modra amodra@gmail.com
Mon Nov 22 00:15:30 GMT 2021


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.  I'm not entirely happy with the patch as-is;  I think
.eh_frame and any other section in dwarf.c:debug_displays that is
*not* stripped by objcopy --strip-debug should not have anything in
the --only-keep-debug file displayed.

I'm not going to apply this patch immediately as I'm not entirely sure
on the intended semantics of --process-links, and Nick, you may
already have a better patch in the works.

	PR 28029
	* objdump.c (dump_bfd): Do not exit early when !is_mainfile
	&& !processlinks, instead just exclude non-debug output.

diff --git a/binutils/objdump.c b/binutils/objdump.c
index 1811e70df93..7e4d2018c71 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -5053,23 +5053,23 @@ dump_bfd (bfd *abfd, bool is_mainfile)
       bfd_map_over_sections (abfd, adjust_addresses, &has_reloc);
     }
 
-  if (! is_mainfile && ! process_links)
-    return;
-
-  if (! dump_debugging_tags && ! suppress_bfd_header)
-    printf (_("\n%s:     file format %s\n"),
-	    sanitize_string (bfd_get_filename (abfd)),
-	    abfd->xvec->name);
-  if (dump_ar_hdrs)
-    print_arelt_descr (stdout, abfd, true, false);
-  if (dump_file_header)
-    dump_bfd_header (abfd);
-  if (dump_private_headers)
-    dump_bfd_private_header (abfd);
-  if (dump_private_options != NULL)
-    dump_target_specific (abfd);
-  if (! dump_debugging_tags && ! suppress_bfd_header)
-    putchar ('\n');
+  if (is_mainfile || process_links)
+    {
+      if (! dump_debugging_tags && ! suppress_bfd_header)
+	printf (_("\n%s:     file format %s\n"),
+		sanitize_string (bfd_get_filename (abfd)),
+		abfd->xvec->name);
+      if (dump_ar_hdrs)
+	print_arelt_descr (stdout, abfd, true, false);
+      if (dump_file_header)
+	dump_bfd_header (abfd);
+      if (dump_private_headers)
+	dump_bfd_private_header (abfd);
+      if (dump_private_options != NULL)
+	dump_target_specific (abfd);
+      if (! dump_debugging_tags && ! suppress_bfd_header)
+	putchar ('\n');
+    }
 
   if (dump_symtab
       || dump_reloc_info
@@ -5112,39 +5112,46 @@ dump_bfd (bfd *abfd, bool is_mainfile)
 	}
     }
 
-  if (dump_section_headers)
-    dump_headers (abfd);
+  if (is_mainfile || process_links)
+    {
+      if (dump_section_headers)
+	dump_headers (abfd);
 
-  if (dump_dynamic_symtab || dump_dynamic_reloc_info
-      || (disassemble && bfd_get_dynamic_symtab_upper_bound (abfd) > 0))
-    dynsyms = slurp_dynamic_symtab (abfd);
+      if (dump_dynamic_symtab || dump_dynamic_reloc_info
+	  || (disassemble && bfd_get_dynamic_symtab_upper_bound (abfd) > 0))
+	dynsyms = slurp_dynamic_symtab (abfd);
 
-  if (disassemble)
-    {
-      synthcount = bfd_get_synthetic_symtab (abfd, symcount, syms,
-					     dynsymcount, dynsyms, &synthsyms);
-      if (synthcount < 0)
-	synthcount = 0;
-    }
+      if (disassemble)
+	{
+	  synthcount = bfd_get_synthetic_symtab (abfd, symcount, syms,
+						 dynsymcount, dynsyms,
+						 &synthsyms);
+	  if (synthcount < 0)
+	    synthcount = 0;
+	}
 
-  if (dump_symtab)
-    dump_symbols (abfd, false);
-  if (dump_dynamic_symtab)
-    dump_symbols (abfd, true);
+      if (dump_symtab)
+	dump_symbols (abfd, false);
+      if (dump_dynamic_symtab)
+	dump_symbols (abfd, true);
+    }
   if (dump_dwarf_section_info)
     dump_dwarf (abfd);
-  if (dump_ctf_section_info)
-    dump_ctf (abfd, dump_ctf_section_name, dump_ctf_parent_name);
-  if (dump_stab_section_info)
-    dump_stabs (abfd);
-  if (dump_reloc_info && ! disassemble)
-    dump_relocs (abfd);
-  if (dump_dynamic_reloc_info && ! disassemble)
-    dump_dynamic_relocs (abfd);
-  if (dump_section_contents)
-    dump_data (abfd);
-  if (disassemble)
-    disassemble_data (abfd);
+  if (is_mainfile || process_links)
+    {
+      if (dump_ctf_section_info)
+	dump_ctf (abfd, dump_ctf_section_name, dump_ctf_parent_name);
+      if (dump_stab_section_info)
+	dump_stabs (abfd);
+      if (dump_reloc_info && ! disassemble)
+	dump_relocs (abfd);
+      if (dump_dynamic_reloc_info && ! disassemble)
+	dump_dynamic_relocs (abfd);
+      if (dump_section_contents)
+	dump_data (abfd);
+      if (disassemble)
+	disassemble_data (abfd);
+    }
 
   if (dump_debugging)
     {

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list