tbaeder / rpms / binutils

Forked from rpms/binutils 2 years ago
Clone
4a7c8e0
diff -rup binutils.orig/binutils/NEWS binutils-2.38/binutils/NEWS
4a7c8e0
--- binutils.orig/binutils/NEWS	2022-03-10 09:13:18.284641005 +0000
4a7c8e0
+++ binutils-2.38/binutils/NEWS	2022-03-10 09:13:26.007586352 +0000
4a7c8e0
@@ -1,5 +1,8 @@
4a7c8e0
 -*- text -*-
4a7c8e0
 
4a7c8e0
+* Add an option to objdump and readelf to prevent attempts to access debuginfod
4a7c8e0
+  servers when following links.
4a7c8e0
+
4a7c8e0
 Changes in 2.38:
4a7c8e0
 
4a7c8e0
 * elfedit: Add --output-abiversion option to update ABIVERSION.
4a7c8e0
diff -rup binutils.orig/binutils/doc/binutils.texi binutils-2.38/binutils/doc/binutils.texi
4a7c8e0
--- binutils.orig/binutils/doc/binutils.texi	2022-03-10 09:13:18.285640998 +0000
4a7c8e0
+++ binutils-2.38/binutils/doc/binutils.texi	2022-03-10 09:13:26.009586338 +0000
4a7c8e0
@@ -2246,6 +2246,8 @@ objdump [@option{-a}|@option{--archive-h
4a7c8e0
          @option{--dwarf}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links]]
4a7c8e0
         [@option{-WK}|@option{--dwarf=follow-links}]
4a7c8e0
         [@option{-WN}|@option{--dwarf=no-follow-links}]
4a7c8e0
+        [@option{-wD}|@option{--dwarf=use-debuginfod}]
4a7c8e0
+        [@option{-wE}|@option{--dwarf=do-not-use-debuginfod}]
4a7c8e0
         [@option{-L}|@option{--process-links}]
4a7c8e0
         [@option{--ctf=}@var{section}]
4a7c8e0
         [@option{-G}|@option{--stabs}]
4a7c8e0
@@ -4879,6 +4881,8 @@ readelf [@option{-a}|@option{--all}]
4a7c8e0
          @option{--debug-dump}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links]]
4a7c8e0
         [@option{-wK}|@option{--debug-dump=follow-links}]
4a7c8e0
         [@option{-wN}|@option{--debug-dump=no-follow-links}]
4a7c8e0
+        [@option{-wD}|@option{--debug-dump=use-debuginfod}]
4a7c8e0
+        [@option{-wE}|@option{--debug-dump=do-not-use-debuginfod}]
4a7c8e0
         [@option{-P}|@option{--process-links}]
4a7c8e0
         [@option{--dwarf-depth=@var{n}}]
4a7c8e0
         [@option{--dwarf-start=@var{n}}]
4a7c8e0
@@ -5504,7 +5508,8 @@ deduced from the input file
4a7c8e0
 @cindex separate debug files
4a7c8e0
 
4a7c8e0
 debuginfod is a web service that indexes ELF/DWARF debugging resources
4a7c8e0
-by build-id and serves them over HTTP.
4a7c8e0
+by build-id and serves them over HTTP.  For more information see:
4a7c8e0
+@emph{https://sourceware.org/elfutils/Debuginfod.html}
4a7c8e0
 
4a7c8e0
 Binutils can be built with the debuginfod client library
4a7c8e0
 @code{libdebuginfod} using the @option{--with-debuginfod} configure option.
4a7c8e0
@@ -5516,6 +5521,10 @@ separate debug files when the files are
4a7c8e0
 debuginfod is packaged with elfutils, starting with version 0.178.
4a7c8e0
 You can get the latest version from `https://sourceware.org/elfutils/'.
4a7c8e0
 
4a7c8e0
+The DWARF info dumping tools (@command{readelf} and @command{objdump})
4a7c8e0
+have options to control when they should access the debuginfod
4a7c8e0
+servers.  By default this access is enabled.
4a7c8e0
+
4a7c8e0
 @node Reporting Bugs
4a7c8e0
 @chapter Reporting Bugs
4a7c8e0
 @cindex bugs
4a7c8e0
Only in binutils-2.38/binutils/doc: binutils.texi.orig
4a7c8e0
diff -rup binutils.orig/binutils/doc/debug.options.texi binutils-2.38/binutils/doc/debug.options.texi
4a7c8e0
--- binutils.orig/binutils/doc/debug.options.texi	2022-03-10 09:13:18.285640998 +0000
4a7c8e0
+++ binutils-2.38/binutils/doc/debug.options.texi	2022-03-10 09:13:26.009586338 +0000
4a7c8e0
@@ -68,10 +68,27 @@ chosen when configuring the binutils via
4a7c8e0
 @option{--enable-follow-debug-links=no} options.  If these are not
4a7c8e0
 used then the default is to enable the following of debug links.
4a7c8e0
 
4a7c8e0
+Note - if support for the debuginfod protocol was enabled when the
4a7c8e0
+binutils were built then this option will also include an attempt to
4a7c8e0
+contact any debuginfod servers mentioned in the @var{DEBUGINFOD_URLS}
4a7c8e0
+environment variable.  This could take some time to resolve.  This
4a7c8e0
+behaviour can be disabled via the @option{=do-not-use-debuginfod} debug
4a7c8e0
+option.
4a7c8e0
+
4a7c8e0
 @item N
4a7c8e0
 @itemx =no-follow-links
4a7c8e0
 Disables the following of links to separate debug info files.
4a7c8e0
 
4a7c8e0
+@item D
4a7c8e0
+@itemx =use-debuginfod
4a7c8e0
+Enables contacting debuginfod servers if there is a need to follow
4a7c8e0
+debug links.  This is the default behaviour.
4a7c8e0
+
4a7c8e0
+@item E
4a7c8e0
+@itemx =do-not-use-debuginfod
4a7c8e0
+Disables contacting debuginfod servers when there is a need to follow
4a7c8e0
+debug links.
4a7c8e0
+
4a7c8e0
 @item l
4a7c8e0
 @itemx =rawline
4a7c8e0
 Displays the contents of the @samp{.debug_line} section in a raw
4a7c8e0
diff -rup binutils.orig/binutils/dwarf.c binutils-2.38/binutils/dwarf.c
4a7c8e0
--- binutils.orig/binutils/dwarf.c	2022-03-10 09:13:18.283641012 +0000
4a7c8e0
+++ binutils-2.38/binutils/dwarf.c	2022-03-10 09:13:26.010586331 +0000
4a7c8e0
@@ -109,6 +109,9 @@ int do_debug_cu_index;
4a7c8e0
 int do_wide;
4a7c8e0
 int do_debug_links;
4a7c8e0
 int do_follow_links = DEFAULT_FOR_FOLLOW_LINKS;
4a7c8e0
+#ifdef HAVE_LIBDEBUGINFOD
4a7c8e0
+int use_debuginfod = 1;
4a7c8e0
+#endif
4a7c8e0
 bool do_checks;
4a7c8e0
 
4a7c8e0
 int dwarf_cutoff_level = -1;
4a7c8e0
@@ -11038,7 +11041,7 @@ debuginfod_fetch_separate_debug_info (st
4a7c8e0
 
4a7c8e0
   return false;
4a7c8e0
 }
4a7c8e0
-#endif
4a7c8e0
+#endif /* HAVE_LIBDEBUGINFOD  */
4a7c8e0
 
4a7c8e0
 static void *
4a7c8e0
 load_separate_debug_info (const char *            main_filename,
4a7c8e0
@@ -11157,9 +11160,10 @@ load_separate_debug_info (const char *
4a7c8e0
   {
4a7c8e0
     char * tmp_filename;
4a7c8e0
 
4a7c8e0
-    if (debuginfod_fetch_separate_debug_info (xlink,
4a7c8e0
-                                              & tmp_filename,
4a7c8e0
-                                              file))
4a7c8e0
+    if (use_debuginfod
4a7c8e0
+	&& debuginfod_fetch_separate_debug_info (xlink,
4a7c8e0
+						 & tmp_filename,
4a7c8e0
+						 file))
4a7c8e0
       {
4a7c8e0
         /* File successfully downloaded from server, replace
4a7c8e0
            debug_filename with the file's path.  */
4a7c8e0
@@ -11207,13 +11211,15 @@ load_separate_debug_info (const char *
4a7c8e0
       warn (_("tried: %s\n"), debug_filename);
4a7c8e0
 
4a7c8e0
 #if HAVE_LIBDEBUGINFOD
4a7c8e0
-      {
4a7c8e0
-	char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
4a7c8e0
-	if (urls == NULL)
4a7c8e0
-	  urls = "";
4a7c8e0
+      if (use_debuginfod)
4a7c8e0
+	{
4a7c8e0
+	  char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
4a7c8e0
 
4a7c8e0
-	warn (_("tried: DEBUGINFOD_URLS=%s\n"), urls);
4a7c8e0
-      }
4a7c8e0
+	  if (urls == NULL)
4a7c8e0
+	    urls = "";
4a7c8e0
+
4a7c8e0
+	  warn (_("tried: DEBUGINFOD_URLS=%s\n"), urls);
4a7c8e0
+	}
4a7c8e0
 #endif
4a7c8e0
     }
4a7c8e0
 
4a7c8e0
@@ -11707,6 +11713,9 @@ dwarf_select_sections_by_names (const ch
4a7c8e0
       { "aranges", & do_debug_aranges, 1 },
4a7c8e0
       { "cu_index", & do_debug_cu_index, 1 },
4a7c8e0
       { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED },
4a7c8e0
+#ifdef HAVE_LIBDEBUGINFOD
4a7c8e0
+      { "do-not-use-debuginfod", & use_debuginfod, 0 },
4a7c8e0
+#endif
4a7c8e0
       { "follow-links", & do_follow_links, 1 },
4a7c8e0
       { "frames", & do_debug_frames, 1 },
4a7c8e0
       { "frames-interp", & do_debug_frames_interp, 1 },
4a7c8e0
@@ -11730,6 +11739,9 @@ dwarf_select_sections_by_names (const ch
4a7c8e0
       { "trace_abbrev", & do_trace_abbrevs, 1 },
4a7c8e0
       { "trace_aranges", & do_trace_aranges, 1 },
4a7c8e0
       { "trace_info", & do_trace_info, 1 },
4a7c8e0
+#ifdef HAVE_LIBDEBUGINFOD
4a7c8e0
+      { "use-debuginfod", & use_debuginfod, 1 },
4a7c8e0
+#endif
4a7c8e0
       { NULL, NULL, 0 }
4a7c8e0
     };
4a7c8e0
 
4a7c8e0
@@ -11783,6 +11795,10 @@ dwarf_select_sections_by_letters (const
4a7c8e0
       case 'A':	do_debug_addr = 1; break;
4a7c8e0
       case 'a':	do_debug_abbrevs = 1; break;
4a7c8e0
       case 'c':	do_debug_cu_index = 1; break;
4a7c8e0
+#ifdef HAVE_LIBDEBUGINFOD
4a7c8e0
+      case 'D': use_debuginfod = 1; break;
4a7c8e0
+      case 'E': use_debuginfod = 0; break;
4a7c8e0
+#endif
4a7c8e0
       case 'F':	do_debug_frames_interp = 1; /* Fall through.  */
4a7c8e0
       case 'f':	do_debug_frames = 1; break;
4a7c8e0
       case 'g':	do_gdb_index = 1; break;
4a7c8e0
diff -rup binutils.orig/binutils/dwarf.h binutils-2.38/binutils/dwarf.h
4a7c8e0
--- binutils.orig/binutils/dwarf.h	2022-03-10 09:13:18.284641005 +0000
4a7c8e0
+++ binutils-2.38/binutils/dwarf.h	2022-03-10 09:13:26.010586331 +0000
4a7c8e0
@@ -224,6 +224,9 @@ extern int do_debug_cu_index;
4a7c8e0
 extern int do_wide;
4a7c8e0
 extern int do_debug_links;
4a7c8e0
 extern int do_follow_links;
4a7c8e0
+#ifdef HAVE_LIBDEBUGINFOD
4a7c8e0
+extern int use_debuginfod;
4a7c8e0
+#endif
4a7c8e0
 extern bool do_checks;
4a7c8e0
 
4a7c8e0
 extern int dwarf_cutoff_level;
4a7c8e0
diff -rup binutils.orig/binutils/objdump.c binutils-2.38/binutils/objdump.c
4a7c8e0
--- binutils.orig/binutils/objdump.c	2022-03-10 09:13:18.283641012 +0000
4a7c8e0
+++ binutils-2.38/binutils/objdump.c	2022-03-10 09:13:26.011586324 +0000
4a7c8e0
@@ -281,6 +281,14 @@ usage (FILE *stream, int status)
4a7c8e0
                            Do not follow links to separate debug info files\n\
4a7c8e0
                             (default)\n"));
4a7c8e0
 #endif
4a7c8e0
+#if HAVE_LIBDEBUGINFOD
4a7c8e0
+  fprintf (stream, _("\
4a7c8e0
+  -WD --dwarf=use-debuginfod\n\
4a7c8e0
+                           When following links, also query debuginfod servers (default)\n"));
4a7c8e0
+  fprintf (stream, _("\
4a7c8e0
+  -WE --dwarf=do-not-use-debuginfod\n\
4a7c8e0
+                           When following links, do not query debuginfod servers\n"));
4a7c8e0
+#endif
4a7c8e0
   fprintf (stream, _("\
4a7c8e0
   -L, --process-links      Display the contents of non-debug sections in\n\
4a7c8e0
                             separate debuginfo files.  (Implies -WK)\n"));
4a7c8e0
Only in binutils-2.38/binutils/: objdump.c.orig
4a7c8e0
diff -rup binutils.orig/binutils/readelf.c binutils-2.38/binutils/readelf.c
4a7c8e0
--- binutils.orig/binutils/readelf.c	2022-03-10 09:13:18.302640878 +0000
4a7c8e0
+++ binutils-2.38/binutils/readelf.c	2022-03-10 09:13:26.012586316 +0000
4a7c8e0
@@ -5126,6 +5126,14 @@ usage (FILE * stream)
4a7c8e0
                          Do not follow links to separate debug info files\n\
4a7c8e0
                           (default)\n"));
4a7c8e0
 #endif
4a7c8e0
+#if HAVE_LIBDEBUGINFOD
4a7c8e0
+  fprintf (stream, _("\
4a7c8e0
+  -wD --debug-dump=use-debuginfod\n\
4a7c8e0
+                         When following links, also query debuginfod servers (default)\n"));
4a7c8e0
+  fprintf (stream, _("\
4a7c8e0
+  -wE --debug-dump=do-not-use-debuginfod\n\
4a7c8e0
+                         When following links, do not query debuginfod servers\n"));
4a7c8e0
+#endif
4a7c8e0
   fprintf (stream, _("\
4a7c8e0
   --dwarf-depth=N        Do not display DIEs at depth N or greater\n"));
4a7c8e0
   fprintf (stream, _("\
4a7c8e0
Only in binutils-2.38/binutils/: readelf.c.orig
4a7c8e0
diff -rup binutils.orig/binutils/testsuite/binutils-all/debuginfod.exp binutils-2.38/binutils/testsuite/binutils-all/debuginfod.exp
4a7c8e0
--- binutils.orig/binutils/testsuite/binutils-all/debuginfod.exp	2022-03-10 09:13:18.291640956 +0000
4a7c8e0
+++ binutils-2.38/binutils/testsuite/binutils-all/debuginfod.exp	2022-03-10 09:13:26.012586316 +0000
4a7c8e0
@@ -185,8 +185,14 @@ proc test_fetch_debugaltlink { prog prog
4a7c8e0
 }
4a7c8e0
 
4a7c8e0
 if { [regexp ".*DEBUGINFOD.*" $conf_objdump] } {
4a7c8e0
-    test_fetch_debuglink $OBJDUMP "-W"
4a7c8e0
+    test_fetch_debuglink $OBJDUMP "-W -WD"
4a7c8e0
     test_fetch_debugaltlink $OBJDUMP "-Wk"
4a7c8e0
+
4a7c8e0
+    set test "disabling debuginfod access"
4a7c8e0
+    setup_xfail *-*-*
4a7c8e0
+    test_fetch_debuglink $OBJDUMP "-W -WE"
4a7c8e0
+    set test "debuginfod"
4a7c8e0
+
4a7c8e0
 } else {
4a7c8e0
     untested "$test (objdump not configured with debuginfod)"
4a7c8e0
 }
4a7c8e0
@@ -194,6 +200,12 @@ if { [regexp ".*DEBUGINFOD.*" $conf_objd
4a7c8e0
 if { [regexp ".*DEBUGINFOD.*" $conf_readelf] } {
4a7c8e0
     test_fetch_debuglink $READELF "-w"
4a7c8e0
     test_fetch_debugaltlink $READELF "-wk"
4a7c8e0
+
4a7c8e0
+    set test "disabling debuginfod access"
4a7c8e0
+    setup_xfail *-*-*
4a7c8e0
+    test_fetch_debuglink $READELF "-w -wE"
4a7c8e0
+    set test "debuginfod"
4a7c8e0
+
4a7c8e0
 } else {
4a7c8e0
     untested "$test (readelf not configured with debuginfod)"
4a7c8e0
 }