diff options
-rw-r--r-- | binutils/ChangeLog | 17 | ||||
-rw-r--r-- | binutils/NEWS | 3 | ||||
-rw-r--r-- | binutils/doc/binutils.texi | 11 | ||||
-rw-r--r-- | binutils/doc/debug.options.texi | 17 | ||||
-rw-r--r-- | binutils/dwarf.c | 36 | ||||
-rw-r--r-- | binutils/dwarf.h | 3 | ||||
-rw-r--r-- | binutils/objdump.c | 8 | ||||
-rw-r--r-- | binutils/readelf.c | 8 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/debuginfod.exp | 14 |
9 files changed, 105 insertions, 12 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index a355e18..213f871 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,20 @@ +2022-03-10 Nick Clifton <nickc@redhat.com> + + * dwarf.c (use_debuginfod): New variable. Set to 1. + (load_separate_debug_info): Only call + debuginfod_fetch_separate_debug_info is use_debuginfod is true. + (dwarf_select_sections_by_names): Add do-not-use-debuginfod and + use-debuginfod options. + (dwarf_select_sections_by_letters): Add D and E options. + * dwarf.h (use_debuginfod): New extern. + * objdump.c (usage): Mention the new options. + * readelf.c (usage): Likewise. + * doc/binutils.texi: Document the new options. + * doc/debug-options.texi: Describe the new options. + * NEWS: Mention the new feature. + * testsuite/binutils-all/debuginfod.exp: Add tests of the new + options. + 2021-03-06 Maciej W. Rozycki <macro@orcam.me.uk> * testsuite/binutils-all/mips/mips1-branch-alias.d: New test. diff --git a/binutils/NEWS b/binutils/NEWS index c188b46..3c44708 100644 --- a/binutils/NEWS +++ b/binutils/NEWS @@ -1,5 +1,8 @@ -*- text -*- +* Add an option to objdump and readelf to prevent attempts to access debuginfod + servers when following links. + Changes in 2.38: * elfedit: Add --output-abiversion option to update ABIVERSION. diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index 288974b..c73837e 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -2246,6 +2246,8 @@ objdump [@option{-a}|@option{--archive-headers}] @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]] [@option{-WK}|@option{--dwarf=follow-links}] [@option{-WN}|@option{--dwarf=no-follow-links}] + [@option{-wD}|@option{--dwarf=use-debuginfod}] + [@option{-wE}|@option{--dwarf=do-not-use-debuginfod}] [@option{-L}|@option{--process-links}] [@option{--ctf=}@var{section}] [@option{-G}|@option{--stabs}] @@ -4883,6 +4885,8 @@ readelf [@option{-a}|@option{--all}] @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]] [@option{-wK}|@option{--debug-dump=follow-links}] [@option{-wN}|@option{--debug-dump=no-follow-links}] + [@option{-wD}|@option{--debug-dump=use-debuginfod}] + [@option{-wE}|@option{--debug-dump=do-not-use-debuginfod}] [@option{-P}|@option{--process-links}] [@option{--dwarf-depth=@var{n}}] [@option{--dwarf-start=@var{n}}] @@ -5508,7 +5512,8 @@ deduced from the input file @cindex separate debug files debuginfod is a web service that indexes ELF/DWARF debugging resources -by build-id and serves them over HTTP. +by build-id and serves them over HTTP. For more information see: +@emph{https://sourceware.org/elfutils/Debuginfod.html} Binutils can be built with the debuginfod client library @code{libdebuginfod} using the @option{--with-debuginfod} configure option. @@ -5520,6 +5525,10 @@ separate debug files when the files are otherwise not found. debuginfod is packaged with elfutils, starting with version 0.178. You can get the latest version from `https://sourceware.org/elfutils/'. +The DWARF info dumping tools (@command{readelf} and @command{objdump}) +have options to control when they should access the debuginfod +servers. By default this access is enabled. + @node Reporting Bugs @chapter Reporting Bugs @cindex bugs diff --git a/binutils/doc/debug.options.texi b/binutils/doc/debug.options.texi index dbe74ff..26477ec 100644 --- a/binutils/doc/debug.options.texi +++ b/binutils/doc/debug.options.texi @@ -68,10 +68,27 @@ chosen when configuring the binutils via the @option{--enable-follow-debug-links=no} options. If these are not used then the default is to enable the following of debug links. +Note - if support for the debuginfod protocol was enabled when the +binutils were built then this option will also include an attempt to +contact any debuginfod servers mentioned in the @var{DEBUGINFOD_URLS} +environment variable. This could take some time to resolve. This +behaviour can be disabled via the @option{=do-not-use-debuginfod} debug +option. + @item N @itemx =no-follow-links Disables the following of links to separate debug info files. +@item D +@itemx =use-debuginfod +Enables contacting debuginfod servers if there is a need to follow +debug links. This is the default behaviour. + +@item E +@itemx =do-not-use-debuginfod +Disables contacting debuginfod servers when there is a need to follow +debug links. + @item l @itemx =rawline Displays the contents of the @samp{.debug_line} section in a raw diff --git a/binutils/dwarf.c b/binutils/dwarf.c index bc33e9f..15b3c81 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -109,6 +109,9 @@ int do_debug_cu_index; int do_wide; int do_debug_links; int do_follow_links = DEFAULT_FOR_FOLLOW_LINKS; +#ifdef HAVE_LIBDEBUGINFOD +int use_debuginfod = 1; +#endif bool do_checks; int dwarf_cutoff_level = -1; @@ -11038,7 +11041,7 @@ debuginfod_fetch_separate_debug_info (struct dwarf_section * section, return false; } -#endif +#endif /* HAVE_LIBDEBUGINFOD */ static void * load_separate_debug_info (const char * main_filename, @@ -11157,9 +11160,10 @@ load_separate_debug_info (const char * main_filename, { char * tmp_filename; - if (debuginfod_fetch_separate_debug_info (xlink, - & tmp_filename, - file)) + if (use_debuginfod + && debuginfod_fetch_separate_debug_info (xlink, + & tmp_filename, + file)) { /* File successfully downloaded from server, replace debug_filename with the file's path. */ @@ -11207,13 +11211,15 @@ load_separate_debug_info (const char * main_filename, warn (_("tried: %s\n"), debug_filename); #if HAVE_LIBDEBUGINFOD - { - char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR); - if (urls == NULL) - urls = ""; + if (use_debuginfod) + { + char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR); - warn (_("tried: DEBUGINFOD_URLS=%s\n"), urls); - } + if (urls == NULL) + urls = ""; + + warn (_("tried: DEBUGINFOD_URLS=%s\n"), urls); + } #endif } @@ -11707,6 +11713,9 @@ dwarf_select_sections_by_names (const char *names) { "aranges", & do_debug_aranges, 1 }, { "cu_index", & do_debug_cu_index, 1 }, { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED }, +#ifdef HAVE_LIBDEBUGINFOD + { "do-not-use-debuginfod", & use_debuginfod, 0 }, +#endif { "follow-links", & do_follow_links, 1 }, { "frames", & do_debug_frames, 1 }, { "frames-interp", & do_debug_frames_interp, 1 }, @@ -11730,6 +11739,9 @@ dwarf_select_sections_by_names (const char *names) { "trace_abbrev", & do_trace_abbrevs, 1 }, { "trace_aranges", & do_trace_aranges, 1 }, { "trace_info", & do_trace_info, 1 }, +#ifdef HAVE_LIBDEBUGINFOD + { "use-debuginfod", & use_debuginfod, 1 }, +#endif { NULL, NULL, 0 } }; @@ -11783,6 +11795,10 @@ dwarf_select_sections_by_letters (const char *letters) case 'A': do_debug_addr = 1; break; case 'a': do_debug_abbrevs = 1; break; case 'c': do_debug_cu_index = 1; break; +#ifdef HAVE_LIBDEBUGINFOD + case 'D': use_debuginfod = 1; break; + case 'E': use_debuginfod = 0; break; +#endif case 'F': do_debug_frames_interp = 1; /* Fall through. */ case 'f': do_debug_frames = 1; break; case 'g': do_gdb_index = 1; break; diff --git a/binutils/dwarf.h b/binutils/dwarf.h index 1843071..4fc62ab 100644 --- a/binutils/dwarf.h +++ b/binutils/dwarf.h @@ -224,6 +224,9 @@ extern int do_debug_cu_index; extern int do_wide; extern int do_debug_links; extern int do_follow_links; +#ifdef HAVE_LIBDEBUGINFOD +extern int use_debuginfod; +#endif extern bool do_checks; extern int dwarf_cutoff_level; diff --git a/binutils/objdump.c b/binutils/objdump.c index 24e9186..8e1c9cb 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -282,6 +282,14 @@ usage (FILE *stream, int status) Do not follow links to separate debug info files\n\ (default)\n")); #endif +#if HAVE_LIBDEBUGINFOD + fprintf (stream, _("\ + -WD --dwarf=use-debuginfod\n\ + When following links, also query debuginfod servers (default)\n")); + fprintf (stream, _("\ + -WE --dwarf=do-not-use-debuginfod\n\ + When following links, do not query debuginfod servers\n")); +#endif fprintf (stream, _("\ -L, --process-links Display the contents of non-debug sections in\n\ separate debuginfo files. (Implies -WK)\n")); diff --git a/binutils/readelf.c b/binutils/readelf.c index 16efe1d..8b46052 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -5127,6 +5127,14 @@ usage (FILE * stream) Do not follow links to separate debug info files\n\ (default)\n")); #endif +#if HAVE_LIBDEBUGINFOD + fprintf (stream, _("\ + -wD --debug-dump=use-debuginfod\n\ + When following links, also query debuginfod servers (default)\n")); + fprintf (stream, _("\ + -wE --debug-dump=do-not-use-debuginfod\n\ + When following links, do not query debuginfod servers\n")); +#endif fprintf (stream, _("\ --dwarf-depth=N Do not display DIEs at depth N or greater\n")); fprintf (stream, _("\ diff --git a/binutils/testsuite/binutils-all/debuginfod.exp b/binutils/testsuite/binutils-all/debuginfod.exp index 96543b2..f5935ad 100644 --- a/binutils/testsuite/binutils-all/debuginfod.exp +++ b/binutils/testsuite/binutils-all/debuginfod.exp @@ -185,8 +185,14 @@ proc test_fetch_debugaltlink { prog progargs } { } if { [regexp ".*DEBUGINFOD.*" $conf_objdump] } { - test_fetch_debuglink $OBJDUMP "-W" + test_fetch_debuglink $OBJDUMP "-W -WD" test_fetch_debugaltlink $OBJDUMP "-Wk" + + set test "disabling debuginfod access" + setup_xfail *-*-* + test_fetch_debuglink $OBJDUMP "-W -WE" + set test "debuginfod" + } else { untested "$test (objdump not configured with debuginfod)" } @@ -194,6 +200,12 @@ if { [regexp ".*DEBUGINFOD.*" $conf_objdump] } { if { [regexp ".*DEBUGINFOD.*" $conf_readelf] } { test_fetch_debuglink $READELF "-w" test_fetch_debugaltlink $READELF "-wk" + + set test "disabling debuginfod access" + setup_xfail *-*-* + test_fetch_debuglink $READELF "-w -wE" + set test "debuginfod" + } else { untested "$test (readelf not configured with debuginfod)" } |