binutils-do-not-use-debuginfod.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. diff -rup binutils.orig/binutils/NEWS binutils-2.38/binutils/NEWS
  2. --- binutils.orig/binutils/NEWS 2022-03-10 09:13:18.284641005 +0000
  3. +++ binutils-2.38/binutils/NEWS 2022-03-10 09:13:26.007586352 +0000
  4. @@ -1,5 +1,8 @@
  5. -*- text -*-
  6. +* Add an option to objdump and readelf to prevent attempts to access debuginfod
  7. + servers when following links.
  8. +
  9. Changes in 2.38:
  10. * elfedit: Add --output-abiversion option to update ABIVERSION.
  11. diff -rup binutils.orig/binutils/doc/binutils.texi binutils-2.38/binutils/doc/binutils.texi
  12. --- binutils.orig/binutils/doc/binutils.texi 2022-03-10 09:13:18.285640998 +0000
  13. +++ binutils-2.38/binutils/doc/binutils.texi 2022-03-10 09:13:26.009586338 +0000
  14. @@ -2246,6 +2246,8 @@ objdump [@option{-a}|@option{--archive-h
  15. @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]]
  16. [@option{-WK}|@option{--dwarf=follow-links}]
  17. [@option{-WN}|@option{--dwarf=no-follow-links}]
  18. + [@option{-wD}|@option{--dwarf=use-debuginfod}]
  19. + [@option{-wE}|@option{--dwarf=do-not-use-debuginfod}]
  20. [@option{-L}|@option{--process-links}]
  21. [@option{--ctf=}@var{section}]
  22. [@option{-G}|@option{--stabs}]
  23. @@ -4879,6 +4881,8 @@ readelf [@option{-a}|@option{--all}]
  24. @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]]
  25. [@option{-wK}|@option{--debug-dump=follow-links}]
  26. [@option{-wN}|@option{--debug-dump=no-follow-links}]
  27. + [@option{-wD}|@option{--debug-dump=use-debuginfod}]
  28. + [@option{-wE}|@option{--debug-dump=do-not-use-debuginfod}]
  29. [@option{-P}|@option{--process-links}]
  30. [@option{--dwarf-depth=@var{n}}]
  31. [@option{--dwarf-start=@var{n}}]
  32. @@ -5504,7 +5508,8 @@ deduced from the input file
  33. @cindex separate debug files
  34. debuginfod is a web service that indexes ELF/DWARF debugging resources
  35. -by build-id and serves them over HTTP.
  36. +by build-id and serves them over HTTP. For more information see:
  37. +@emph{https://sourceware.org/elfutils/Debuginfod.html}
  38. Binutils can be built with the debuginfod client library
  39. @code{libdebuginfod} using the @option{--with-debuginfod} configure option.
  40. @@ -5516,6 +5521,10 @@ separate debug files when the files are
  41. debuginfod is packaged with elfutils, starting with version 0.178.
  42. You can get the latest version from `https://sourceware.org/elfutils/'.
  43. +The DWARF info dumping tools (@command{readelf} and @command{objdump})
  44. +have options to control when they should access the debuginfod
  45. +servers. By default this access is enabled.
  46. +
  47. @node Reporting Bugs
  48. @chapter Reporting Bugs
  49. @cindex bugs
  50. Only in binutils-2.38/binutils/doc: binutils.texi.orig
  51. diff -rup binutils.orig/binutils/doc/debug.options.texi binutils-2.38/binutils/doc/debug.options.texi
  52. --- binutils.orig/binutils/doc/debug.options.texi 2022-03-10 09:13:18.285640998 +0000
  53. +++ binutils-2.38/binutils/doc/debug.options.texi 2022-03-10 09:13:26.009586338 +0000
  54. @@ -68,10 +68,27 @@ chosen when configuring the binutils via
  55. @option{--enable-follow-debug-links=no} options. If these are not
  56. used then the default is to enable the following of debug links.
  57. +Note - if support for the debuginfod protocol was enabled when the
  58. +binutils were built then this option will also include an attempt to
  59. +contact any debuginfod servers mentioned in the @var{DEBUGINFOD_URLS}
  60. +environment variable. This could take some time to resolve. This
  61. +behaviour can be disabled via the @option{=do-not-use-debuginfod} debug
  62. +option.
  63. +
  64. @item N
  65. @itemx =no-follow-links
  66. Disables the following of links to separate debug info files.
  67. +@item D
  68. +@itemx =use-debuginfod
  69. +Enables contacting debuginfod servers if there is a need to follow
  70. +debug links. This is the default behaviour.
  71. +
  72. +@item E
  73. +@itemx =do-not-use-debuginfod
  74. +Disables contacting debuginfod servers when there is a need to follow
  75. +debug links.
  76. +
  77. @item l
  78. @itemx =rawline
  79. Displays the contents of the @samp{.debug_line} section in a raw
  80. diff -rup binutils.orig/binutils/dwarf.c binutils-2.38/binutils/dwarf.c
  81. --- binutils.orig/binutils/dwarf.c 2022-03-10 09:13:18.283641012 +0000
  82. +++ binutils-2.38/binutils/dwarf.c 2022-03-10 09:13:26.010586331 +0000
  83. @@ -109,6 +109,9 @@ int do_debug_cu_index;
  84. int do_wide;
  85. int do_debug_links;
  86. int do_follow_links = DEFAULT_FOR_FOLLOW_LINKS;
  87. +#ifdef HAVE_LIBDEBUGINFOD
  88. +int use_debuginfod = 1;
  89. +#endif
  90. bool do_checks;
  91. int dwarf_cutoff_level = -1;
  92. @@ -11038,7 +11041,7 @@ debuginfod_fetch_separate_debug_info (st
  93. return false;
  94. }
  95. -#endif
  96. +#endif /* HAVE_LIBDEBUGINFOD */
  97. static void *
  98. load_separate_debug_info (const char * main_filename,
  99. @@ -11157,9 +11160,10 @@ load_separate_debug_info (const char *
  100. {
  101. char * tmp_filename;
  102. - if (debuginfod_fetch_separate_debug_info (xlink,
  103. - & tmp_filename,
  104. - file))
  105. + if (use_debuginfod
  106. + && debuginfod_fetch_separate_debug_info (xlink,
  107. + & tmp_filename,
  108. + file))
  109. {
  110. /* File successfully downloaded from server, replace
  111. debug_filename with the file's path. */
  112. @@ -11207,13 +11211,15 @@ load_separate_debug_info (const char *
  113. warn (_("tried: %s\n"), debug_filename);
  114. #if HAVE_LIBDEBUGINFOD
  115. - {
  116. - char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
  117. - if (urls == NULL)
  118. - urls = "";
  119. + if (use_debuginfod)
  120. + {
  121. + char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
  122. - warn (_("tried: DEBUGINFOD_URLS=%s\n"), urls);
  123. - }
  124. + if (urls == NULL)
  125. + urls = "";
  126. +
  127. + warn (_("tried: DEBUGINFOD_URLS=%s\n"), urls);
  128. + }
  129. #endif
  130. }
  131. @@ -11707,6 +11713,9 @@ dwarf_select_sections_by_names (const ch
  132. { "aranges", & do_debug_aranges, 1 },
  133. { "cu_index", & do_debug_cu_index, 1 },
  134. { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED },
  135. +#ifdef HAVE_LIBDEBUGINFOD
  136. + { "do-not-use-debuginfod", & use_debuginfod, 0 },
  137. +#endif
  138. { "follow-links", & do_follow_links, 1 },
  139. { "frames", & do_debug_frames, 1 },
  140. { "frames-interp", & do_debug_frames_interp, 1 },
  141. @@ -11730,6 +11739,9 @@ dwarf_select_sections_by_names (const ch
  142. { "trace_abbrev", & do_trace_abbrevs, 1 },
  143. { "trace_aranges", & do_trace_aranges, 1 },
  144. { "trace_info", & do_trace_info, 1 },
  145. +#ifdef HAVE_LIBDEBUGINFOD
  146. + { "use-debuginfod", & use_debuginfod, 1 },
  147. +#endif
  148. { NULL, NULL, 0 }
  149. };
  150. @@ -11783,6 +11795,10 @@ dwarf_select_sections_by_letters (const
  151. case 'A': do_debug_addr = 1; break;
  152. case 'a': do_debug_abbrevs = 1; break;
  153. case 'c': do_debug_cu_index = 1; break;
  154. +#ifdef HAVE_LIBDEBUGINFOD
  155. + case 'D': use_debuginfod = 1; break;
  156. + case 'E': use_debuginfod = 0; break;
  157. +#endif
  158. case 'F': do_debug_frames_interp = 1; /* Fall through. */
  159. case 'f': do_debug_frames = 1; break;
  160. case 'g': do_gdb_index = 1; break;
  161. diff -rup binutils.orig/binutils/dwarf.h binutils-2.38/binutils/dwarf.h
  162. --- binutils.orig/binutils/dwarf.h 2022-03-10 09:13:18.284641005 +0000
  163. +++ binutils-2.38/binutils/dwarf.h 2022-03-10 09:13:26.010586331 +0000
  164. @@ -224,6 +224,9 @@ extern int do_debug_cu_index;
  165. extern int do_wide;
  166. extern int do_debug_links;
  167. extern int do_follow_links;
  168. +#ifdef HAVE_LIBDEBUGINFOD
  169. +extern int use_debuginfod;
  170. +#endif
  171. extern bool do_checks;
  172. extern int dwarf_cutoff_level;
  173. diff -rup binutils.orig/binutils/objdump.c binutils-2.38/binutils/objdump.c
  174. --- binutils.orig/binutils/objdump.c 2022-03-10 09:13:18.283641012 +0000
  175. +++ binutils-2.38/binutils/objdump.c 2022-03-10 09:13:26.011586324 +0000
  176. @@ -281,6 +281,14 @@ usage (FILE *stream, int status)
  177. Do not follow links to separate debug info files\n\
  178. (default)\n"));
  179. #endif
  180. +#if HAVE_LIBDEBUGINFOD
  181. + fprintf (stream, _("\
  182. + -WD --dwarf=use-debuginfod\n\
  183. + When following links, also query debuginfod servers (default)\n"));
  184. + fprintf (stream, _("\
  185. + -WE --dwarf=do-not-use-debuginfod\n\
  186. + When following links, do not query debuginfod servers\n"));
  187. +#endif
  188. fprintf (stream, _("\
  189. -L, --process-links Display the contents of non-debug sections in\n\
  190. separate debuginfo files. (Implies -WK)\n"));
  191. Only in binutils-2.38/binutils/: objdump.c.orig
  192. diff -rup binutils.orig/binutils/readelf.c binutils-2.38/binutils/readelf.c
  193. --- binutils.orig/binutils/readelf.c 2022-03-10 09:13:18.302640878 +0000
  194. +++ binutils-2.38/binutils/readelf.c 2022-03-10 09:13:26.012586316 +0000
  195. @@ -5126,6 +5126,14 @@ usage (FILE * stream)
  196. Do not follow links to separate debug info files\n\
  197. (default)\n"));
  198. #endif
  199. +#if HAVE_LIBDEBUGINFOD
  200. + fprintf (stream, _("\
  201. + -wD --debug-dump=use-debuginfod\n\
  202. + When following links, also query debuginfod servers (default)\n"));
  203. + fprintf (stream, _("\
  204. + -wE --debug-dump=do-not-use-debuginfod\n\
  205. + When following links, do not query debuginfod servers\n"));
  206. +#endif
  207. fprintf (stream, _("\
  208. --dwarf-depth=N Do not display DIEs at depth N or greater\n"));
  209. fprintf (stream, _("\
  210. Only in binutils-2.38/binutils/: readelf.c.orig
  211. diff -rup binutils.orig/binutils/testsuite/binutils-all/debuginfod.exp binutils-2.38/binutils/testsuite/binutils-all/debuginfod.exp
  212. --- binutils.orig/binutils/testsuite/binutils-all/debuginfod.exp 2022-03-10 09:13:18.291640956 +0000
  213. +++ binutils-2.38/binutils/testsuite/binutils-all/debuginfod.exp 2022-03-10 09:13:26.012586316 +0000
  214. @@ -185,8 +185,14 @@ proc test_fetch_debugaltlink { prog prog
  215. }
  216. if { [regexp ".*DEBUGINFOD.*" $conf_objdump] } {
  217. - test_fetch_debuglink $OBJDUMP "-W"
  218. + test_fetch_debuglink $OBJDUMP "-W -WD"
  219. test_fetch_debugaltlink $OBJDUMP "-Wk"
  220. +
  221. + set test "disabling debuginfod access"
  222. + setup_xfail *-*-*
  223. + test_fetch_debuglink $OBJDUMP "-W -WE"
  224. + set test "debuginfod"
  225. +
  226. } else {
  227. untested "$test (objdump not configured with debuginfod)"
  228. }
  229. @@ -194,6 +200,12 @@ if { [regexp ".*DEBUGINFOD.*" $conf_objd
  230. if { [regexp ".*DEBUGINFOD.*" $conf_readelf] } {
  231. test_fetch_debuglink $READELF "-w"
  232. test_fetch_debugaltlink $READELF "-wk"
  233. +
  234. + set test "disabling debuginfod access"
  235. + setup_xfail *-*-*
  236. + test_fetch_debuglink $READELF "-w -wE"
  237. + set test "debuginfod"
  238. +
  239. } else {
  240. untested "$test (readelf not configured with debuginfod)"
  241. }