Compare commits

...
Sign in to create a new pull request.

19 commits

Author SHA1 Message Date
Nick Clifton
61fa7eb43b Linker: Do not associate allocated reloc sections with the .symtab section. (#2166419) 2023-03-30 16:07:03 +01:00
Miloš Prchlík
9a32411e0c tests: fix tmt plan setup, "how: beakerlib" is no longer supported
Tests set their "framework" key correctly to "beakerlib", the correct setting for plan is therefore "tmt". This was not needed until recently, the old form was deprecated but still supported by Testing Farm, but not anymore.
2022-12-14 10:12:29 +01:00
yahmad
5e53841477 - Fic configuration of s390x binutils so that it does not include support for extraneous targets. (#2139143)
- Fix readelf's decoding of files with no sections.  (#2131609)
- Stop potential infinite loop in the binutils DWARF parser.  (#2122675)

NOTE: Getting back in sync. Previous commit was done by mistake.
(commit f3e2e5419d)
2022-11-17 16:06:53 +01:00
yahmad
f3e2e5419d - Stop a potential infinite loop in the binutils DWARF parser. (#2122675) 2022-09-07 16:25:20 +02:00
yahmad
f4b048a78b Improving the performance of bfd function lookup_func_by_offset 2022-09-07 11:51:30 +02:00
yahmad
d8e4b1f5a0 - Fixes warning when running strip on an object file (#2114597) 2022-08-10 20:21:06 +02:00
yahmad
1c29d08ae4 - Add the --package-metadata option to the linkers. (#2099999) 2022-08-08 17:19:27 +02:00
yahmad
c1349c74c4 - Restore the use of --enable-64-bit-bfd for the AArch64 and riscv64 targets.
- Check and enable 64-bit bfd on aarch64 and riscv64.
2022-08-04 10:29:09 +02:00
Nick Clifton
2571e2aaa2 Move update to correct patch file 2022-06-30 15:47:28 +01:00
Nick Clifton
c35887d498 Fix a problem honouring readelf's -wE and -wN command line options. 2022-06-30 15:33:18 +01:00
yahmad
6009a5bc1d Add back again deleted sources 2022-06-09 12:37:59 +02:00
yahmad
6007cbaca0 - Fix bug in binutils.spec file that was causing the wrong linker flags to be used.
- Change the ld man page so that it says that --enable-new-dtags is the default.  (#2090818)
2022-06-09 00:06:20 +02:00
Nick Clifton
db11ef8049 Stop readelf and objdump from unnecessarily following links. (#2086863) 2022-05-21 14:37:21 +01:00
Nick Clifton
1cb629116d Add patch as well 2022-05-20 09:12:25 +01:00
Nick Clifton
2777742ac4 Add support for generating static PIE binaries for s390x. (#2088331) 2022-05-20 09:12:13 +01:00
yahmad
5c24001c4c - Fix description of gold subpackage so that it does not include the Requires fields. (#2082919) 2022-05-19 16:21:35 +02:00
yahmad
d56d81b64e - Fix description of gold subpackage so that it does not include the Requires fields. (#2082919) 2022-05-19 16:04:27 +02:00
Nick Clifton
325f0aa6e2 Add an option to objdump/readelf to disable accessing debuginfod servers.
Resolves: #2051741
2022-03-10 11:29:11 +00:00
Nick Clifton
33b2864149 Fix a potential illegal memory access parsing a corrupt ELF format file.
Resolves: #2052522
2022-02-10 10:47:28 +00:00
14 changed files with 3241 additions and 28 deletions

View file

@ -0,0 +1,15 @@
--- binutils.orig/binutils/dwarf.c 2022-08-31 11:58:08.918685348 +0100
+++ binutils-2.39/binutils/dwarf.c 2022-08-31 15:24:13.881865797 +0100
@@ -6365,7 +6365,11 @@ display_debug_abbrev (struct dwarf_secti
list->start_of_next_abbrevs = start;
}
else
- start = list->start_of_next_abbrevs;
+ {
+ if (start == list->start_of_next_abbrevs)
+ break;
+ start = list->start_of_next_abbrevs;
+ }
if (list->first_abbrev == NULL)
continue;

View file

@ -0,0 +1,124 @@
diff -rup binutils.orig/bfd/dwarf2.c binutils-2.37/bfd/dwarf2.c
--- binutils.orig/bfd/dwarf2.c 2022-08-25 17:21:09.023295361 +0200
+++ binutils-2.37/bfd/dwarf2.c 2022-09-05 14:26:02.396271516 +0200
@@ -36,6 +36,7 @@
#include "elf-bfd.h"
#include "dwarf2.h"
#include "hashtab.h"
+#include "splay-tree.h"
/* The data in the .debug_line statement prologue looks like this. */
@@ -82,6 +83,45 @@ struct adjusted_section
bfd_vma adj_vma;
};
+struct addr_range
+{
+ bfd_byte *start;
+ bfd_byte *end;
+};
+
+/* Return true if address range do intersect. */
+
+static bool
+addr_range_intersects (struct addr_range *r1, struct addr_range *r2)
+{
+ return (r1->start <= r2->start && r2->start < r1->end)
+ || (r1->start <= (r2->end - 1) && (r2->end - 1) < r1->end);
+}
+
+/* Compare function for splay tree of addr_ranges. */
+
+static int
+splay_tree_compare_addr_range (splay_tree_key xa, splay_tree_key xb)
+{
+ struct addr_range *r1 = (struct addr_range *) xa;
+ struct addr_range *r2 = (struct addr_range *) xb;
+
+ if (addr_range_intersects (r1, r2) || addr_range_intersects (r2, r1))
+ return 0;
+ else if (r1->end <= r2->start)
+ return -1;
+ else
+ return 1;
+}
+
+/* Splay tree release function for keys (addr_range). */
+
+static void
+splay_tree_free_addr_range (splay_tree_key key)
+{
+ free ((struct addr_range *)key);
+}
+
struct dwarf2_debug_file
{
/* The actual bfd from which debug info was loaded. Might be
@@ -147,6 +187,9 @@ struct dwarf2_debug_file
/* Hash table to map offsets to decoded abbrevs. */
htab_t abbrev_offsets;
+
+ /* Splay tree to map info_ptr address to compilation units. */
+ splay_tree comp_unit_tree;
};
struct dwarf2_debug
@@ -2948,16 +2991,12 @@ find_abstract_instance (struct comp_unit
else
{
/* Check other CUs to see if they contain the abbrev. */
- struct comp_unit *u;
-
- for (u = unit->prev_unit; u != NULL; u = u->prev_unit)
- if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr)
- break;
-
- if (u == NULL)
- for (u = unit->next_unit; u != NULL; u = u->next_unit)
- if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr)
- break;
+ struct comp_unit *u = NULL;
+ struct addr_range range = { info_ptr, info_ptr };
+ splay_tree_node v = splay_tree_lookup (unit->file->comp_unit_tree,
+ (splay_tree_key)&range);
+ if (v != NULL)
+ u = (struct comp_unit *)v->value;
if (attr_ptr->form == DW_FORM_ref_addr)
while (u == NULL)
@@ -4837,6 +4876,22 @@ stash_comp_unit (struct dwarf2_debug *st
info_ptr_unit, offset_size);
if (each)
{
+ if (file->comp_unit_tree == NULL)
+ file->comp_unit_tree
+ = splay_tree_new (splay_tree_compare_addr_range,
+ splay_tree_free_addr_range, NULL);
+
+ struct addr_range *r
+ = (struct addr_range *)bfd_malloc (sizeof (struct addr_range));
+ r->start = each->info_ptr_unit;
+ r->end = each->end_ptr;
+ splay_tree_node v = splay_tree_lookup (file->comp_unit_tree,
+ (splay_tree_key)r);
+ if (v != NULL || r->end <= r->start)
+ abort ();
+ splay_tree_insert (file->comp_unit_tree, (splay_tree_key)r,
+ (splay_tree_value)each);
+
if (file->all_comp_units)
file->all_comp_units->prev_unit = each;
else
@@ -5288,6 +5343,8 @@ _bfd_dwarf2_cleanup_debug_info (bfd *abf
free (file->line_table->dirs);
}
htab_delete (file->abbrev_offsets);
+ if (file->comp_unit_tree != NULL)
+ splay_tree_delete (file->comp_unit_tree);
free (file->dwarf_line_str_buffer);
free (file->dwarf_str_buffer);
Only in binutils-2.37/bfd: dwarf2.c.orig
Only in binutils-2.37/bfd: dwarf2.c.rej

View file

@ -0,0 +1,971 @@
diff -rup binutils.orig/binutils/NEWS binutils-2.37/binutils/NEWS
--- binutils.orig/binutils/NEWS 2022-03-10 10:52:01.090309329 +0000
+++ binutils-2.37/binutils/NEWS 2022-03-10 10:52:35.149087511 +0000
@@ -1,5 +1,8 @@
-*- text -*-
++* Add an option to objdump and readelf to prevent attempts to access debuginfod
++ servers when following links.
++
* Tools which display symbols or strings (readelf, strings, nm, objdump)
have a new command line option which controls how unicode characters are
handled. By default they are treated as normal for the tool. Using
diff -rup binutils.orig/binutils/NEWS.orig binutils-2.37/binutils/NEWS.orig
--- binutils.orig/binutils/NEWS.orig 2022-03-10 10:52:01.072309446 +0000
+++ binutils-2.37/binutils/NEWS.orig 2022-03-10 10:52:09.778252743 +0000
@@ -1,5 +1,17 @@
-*- text -*-
+* Tools which display symbols or strings (readelf, strings, nm, objdump)
+ have a new command line option which controls how unicode characters are
+ handled. By default they are treated as normal for the tool. Using
+ --unicode=locale will display them according to the current locale.
+ Using --unicode=hex will display them as hex byte values, whilst
+ --unicode=escape will display them as escape sequences. In addition
+ using --unicode=highlight will display them as unicode escape sequences
+ highlighted in red (if supported by the output device).
+
+* Support for efi-app-aarch64, efi-rtdrv-aarch64 and efi-bsdrv-aarch64 has been
+ added to objcopy in order to enable UEFI development using binutils.
+
Changes in 2.37:
* The readelf tool has a new command line option which can be used to specify
diff -rup binutils.orig/binutils/NEWS.rej binutils-2.37/binutils/NEWS.rej
--- binutils.orig/binutils/NEWS.rej 2022-03-10 10:52:01.090309329 +0000
+++ binutils-2.37/binutils/NEWS.rej 2022-03-10 10:52:09.778252743 +0000
@@ -1,18 +1,11 @@
--- binutils/NEWS
+++ binutils/NEWS
-@@ -2,6 +2,15 @@
+@@ -1,5 +1,8 @@
+ -*- text -*-
- * Add support for the LoongArch instruction set.
-
-+* Tools which display symbols or strings (readelf, strings, nm, objdump)
-+ have a new command line option which controls how unicode characters are
-+ handled. By default they are treated as normal for the tool. Using
-+ --unicode=locale will display them according to the current locale.
-+ Using --unicode=hex will display them as hex byte values, whilst
-+ --unicode=escape will display them as escape sequences. In addition
-+ using --unicode=highlight will display them as unicode escape sequences
-+ highlighted in red (if supported by the output device).
++* Add an option to objdump and readelf to prevent attempts to access debuginfod
++ servers when following links.
+
- Changes in 2.37:
+ Changes in 2.38:
- * The readelf tool has a new command line option which can be used to specify
+ * elfedit: Add --output-abiversion option to update ABIVERSION.
diff -rup binutils.orig/binutils/doc/binutils.texi binutils-2.37/binutils/doc/binutils.texi
--- binutils.orig/binutils/doc/binutils.texi 2022-03-10 10:52:01.073309440 +0000
+++ binutils-2.37/binutils/doc/binutils.texi 2022-03-10 10:52:09.779252737 +0000
@@ -2241,6 +2241,8 @@ objdump [@option{-a}|@option{--archive-h
@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}]
@@ -4869,6 +4871,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}}]
@@ -5482,7 +5486,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.
@@ -5494,6 +5499,10 @@ separate debug files when the files are
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
Only in binutils-2.37/binutils/doc: binutils.texi.orig
diff -rup binutils.orig/binutils/doc/debug.options.texi binutils-2.37/binutils/doc/debug.options.texi
--- binutils.orig/binutils/doc/debug.options.texi 2022-03-10 10:52:01.073309440 +0000
+++ binutils-2.37/binutils/doc/debug.options.texi 2022-03-10 10:52:09.779252737 +0000
@@ -68,10 +68,27 @@ chosen when configuring the binutils via
@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 -rup binutils.orig/binutils/dwarf.c binutils-2.37/binutils/dwarf.c
--- binutils.orig/binutils/dwarf.c 2022-03-10 10:52:01.066309485 +0000
+++ binutils-2.37/binutils/dwarf.c 2022-03-10 10:52:09.779252737 +0000
@@ -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;
@@ -11003,7 +11006,7 @@ debuginfod_fetch_separate_debug_info (st
return false;
}
-#endif
+#endif /* HAVE_LIBDEBUGINFOD */
static void *
load_separate_debug_info (const char * main_filename,
@@ -11117,9 +11120,10 @@ load_separate_debug_info (const char *
{
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. */
@@ -11167,13 +11171,15 @@ load_separate_debug_info (const char *
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
}
@@ -11547,6 +11553,9 @@ dwarf_select_sections_by_names (const ch
{ "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 },
@@ -11570,6 +11579,9 @@ dwarf_select_sections_by_names (const ch
{ "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 }
};
@@ -11623,6 +11635,10 @@ dwarf_select_sections_by_letters (const
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;
Only in binutils-2.37/binutils/: dwarf.c.orig
diff -rup binutils.orig/binutils/dwarf.h binutils-2.37/binutils/dwarf.h
--- binutils.orig/binutils/dwarf.h 2022-03-10 10:52:01.066309485 +0000
+++ binutils-2.37/binutils/dwarf.h 2022-03-10 10:52:09.780252730 +0000
@@ -221,6 +221,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;
Only in binutils-2.37/binutils/: dwarf.h.orig
diff -rup binutils.orig/binutils/objdump.c binutils-2.37/binutils/objdump.c
--- binutils.orig/binutils/objdump.c 2022-03-10 10:52:01.090309329 +0000
+++ binutils-2.37/binutils/objdump.c 2022-03-10 10:52:09.780252730 +0000
@@ -280,6 +280,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 -rup binutils.orig/binutils/objdump.c.orig binutils-2.37/binutils/objdump.c.orig
--- binutils.orig/binutils/objdump.c.orig 2022-03-10 10:52:01.065309492 +0000
+++ binutils-2.37/binutils/objdump.c.orig 2022-03-10 10:51:55.365346615 +0000
@@ -204,6 +204,18 @@ static const struct objdump_private_desc
/* The list of detected jumps inside a function. */
static struct jump_info *detected_jumps = NULL;
+
+typedef enum unicode_display_type
+{
+ unicode_default = 0,
+ unicode_locale,
+ unicode_escape,
+ unicode_hex,
+ unicode_highlight,
+ unicode_invalid
+} unicode_display_type;
+
+static unicode_display_type unicode_display = unicode_default;
static void usage (FILE *, int) ATTRIBUTE_NORETURN;
static void
@@ -330,6 +342,9 @@ usage (FILE *stream, int status)
fprintf (stream, _("\
-w, --wide Format output for more than 80 columns\n"));
fprintf (stream, _("\
+ -U[d|l|i|x|e|h] Controls the display of UTF-8 unicode characters\n\
+ --unicode=[default|locale|invalid|hex|escape|highlight]\n"));
+ fprintf (stream, _("\
-z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n"));
fprintf (stream, _("\
--start-address=ADDR Only process data whose address is >= ADDR\n"));
@@ -420,17 +435,23 @@ static struct option long_options[]=
{
{"adjust-vma", required_argument, NULL, OPTION_ADJUST_VMA},
{"all-headers", no_argument, NULL, 'x'},
- {"private-headers", no_argument, NULL, 'p'},
- {"private", required_argument, NULL, 'P'},
{"architecture", required_argument, NULL, 'm'},
{"archive-headers", no_argument, NULL, 'a'},
+#ifdef ENABLE_LIBCTF
+ {"ctf", required_argument, NULL, OPTION_CTF},
+ {"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT},
+#endif
{"debugging", no_argument, NULL, 'g'},
{"debugging-tags", no_argument, NULL, 'e'},
{"demangle", optional_argument, NULL, 'C'},
{"disassemble", optional_argument, NULL, 'd'},
{"disassemble-all", no_argument, NULL, 'D'},
- {"disassembler-options", required_argument, NULL, 'M'},
{"disassemble-zeroes", no_argument, NULL, 'z'},
+ {"disassembler-options", required_argument, NULL, 'M'},
+ {"dwarf", optional_argument, NULL, OPTION_DWARF},
+ {"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK},
+ {"dwarf-depth", required_argument, 0, OPTION_DWARF_DEPTH},
+ {"dwarf-start", required_argument, 0, OPTION_DWARF_START},
{"dynamic-reloc", no_argument, NULL, 'R'},
{"dynamic-syms", no_argument, NULL, 'T'},
{"endian", required_argument, NULL, OPTION_ENDIAN},
@@ -440,16 +461,23 @@ static struct option long_options[]=
{"full-contents", no_argument, NULL, 's'},
{"headers", no_argument, NULL, 'h'},
{"help", no_argument, NULL, 'H'},
+ {"include", required_argument, NULL, 'I'},
{"info", no_argument, NULL, 'i'},
+ {"inlines", no_argument, 0, OPTION_INLINES},
+ {"insn-width", required_argument, NULL, OPTION_INSN_WIDTH},
{"line-numbers", no_argument, NULL, 'l'},
- {"no-show-raw-insn", no_argument, &show_raw_insn, -1},
{"no-addresses", no_argument, &no_addresses, 1},
- {"process-links", no_argument, &process_links, true},
+ {"no-recurse-limit", no_argument, NULL, OPTION_NO_RECURSE_LIMIT},
+ {"no-recursion-limit", no_argument, NULL, OPTION_NO_RECURSE_LIMIT},
+ {"no-show-raw-insn", no_argument, &show_raw_insn, -1},
+ {"prefix", required_argument, NULL, OPTION_PREFIX},
{"prefix-addresses", no_argument, &prefix_addresses, 1},
+ {"prefix-strip", required_argument, NULL, OPTION_PREFIX_STRIP},
+ {"private", required_argument, NULL, 'P'},
+ {"private-headers", no_argument, NULL, 'p'},
+ {"process-links", no_argument, &process_links, true},
{"recurse-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
{"recursion-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
- {"no-recurse-limit", no_argument, NULL, OPTION_NO_RECURSE_LIMIT},
- {"no-recursion-limit", no_argument, NULL, OPTION_NO_RECURSE_LIMIT},
{"reloc", no_argument, NULL, 'r'},
{"section", required_argument, NULL, 'j'},
{"section-headers", no_argument, NULL, 'h'},
@@ -457,28 +485,16 @@ static struct option long_options[]=
{"source", no_argument, NULL, 'S'},
{"source-comment", optional_argument, NULL, OPTION_SOURCE_COMMENT},
{"special-syms", no_argument, &dump_special_syms, 1},
- {"include", required_argument, NULL, 'I'},
- {"dwarf", optional_argument, NULL, OPTION_DWARF},
-#ifdef ENABLE_LIBCTF
- {"ctf", required_argument, NULL, OPTION_CTF},
- {"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT},
-#endif
{"stabs", no_argument, NULL, 'G'},
{"start-address", required_argument, NULL, OPTION_START_ADDRESS},
{"stop-address", required_argument, NULL, OPTION_STOP_ADDRESS},
{"syms", no_argument, NULL, 't'},
{"target", required_argument, NULL, 'b'},
+ {"unicode", required_argument, NULL, 'U'},
{"version", no_argument, NULL, 'V'},
- {"wide", no_argument, NULL, 'w'},
- {"prefix", required_argument, NULL, OPTION_PREFIX},
- {"prefix-strip", required_argument, NULL, OPTION_PREFIX_STRIP},
- {"insn-width", required_argument, NULL, OPTION_INSN_WIDTH},
- {"dwarf-depth", required_argument, 0, OPTION_DWARF_DEPTH},
- {"dwarf-start", required_argument, 0, OPTION_DWARF_START},
- {"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK},
- {"inlines", no_argument, 0, OPTION_INLINES},
{"visualize-jumps", optional_argument, 0, OPTION_VISUALIZE_JUMPS},
- {0, no_argument, 0, 0}
+ {"wide", no_argument, NULL, 'w'},
+ {NULL, no_argument, NULL, 0}
};
static void
@@ -488,9 +504,121 @@ nonfatal (const char *msg)
exit_status = 1;
}
+/* Convert a potential UTF-8 encoded sequence in IN into characters in OUT.
+ The conversion format is controlled by the unicode_display variable.
+ Returns the number of characters added to OUT.
+ Returns the number of bytes consumed from IN in CONSUMED.
+ Always consumes at least one byte and displays at least one character. */
+
+static unsigned int
+display_utf8 (const unsigned char * in, char * out, unsigned int * consumed)
+{
+ char * orig_out = out;
+ unsigned int nchars = 0;
+ unsigned int j;
+
+ if (unicode_display == unicode_default)
+ goto invalid;
+
+ if (in[0] < 0xc0)
+ goto invalid;
+
+ if ((in[1] & 0xc0) != 0x80)
+ goto invalid;
+
+ if ((in[0] & 0x20) == 0)
+ {
+ nchars = 2;
+ goto valid;
+ }
+
+ if ((in[2] & 0xc0) != 0x80)
+ goto invalid;
+
+ if ((in[0] & 0x10) == 0)
+ {
+ nchars = 3;
+ goto valid;
+ }
+
+ if ((in[3] & 0xc0) != 0x80)
+ goto invalid;
+
+ nchars = 4;
+
+ valid:
+ switch (unicode_display)
+ {
+ case unicode_locale:
+ /* Copy the bytes into the output buffer as is. */
+ memcpy (out, in, nchars);
+ out += nchars;
+ break;
+
+ case unicode_invalid:
+ case unicode_hex:
+ out += sprintf (out, "%c", unicode_display == unicode_hex ? '<' : '{');
+ out += sprintf (out, "0x");
+ for (j = 0; j < nchars; j++)
+ out += sprintf (out, "%02x", in [j]);
+ out += sprintf (out, "%c", unicode_display == unicode_hex ? '>' : '}');
+ break;
+
+ case unicode_highlight:
+ if (isatty (1))
+ out += sprintf (out, "\x1B[31;47m"); /* Red. */
+ /* Fall through. */
+ case unicode_escape:
+ switch (nchars)
+ {
+ case 2:
+ out += sprintf (out, "\\u%02x%02x",
+ ((in[0] & 0x1c) >> 2),
+ ((in[0] & 0x03) << 6) | (in[1] & 0x3f));
+ break;
+
+ case 3:
+ out += sprintf (out, "\\u%02x%02x",
+ ((in[0] & 0x0f) << 4) | ((in[1] & 0x3c) >> 2),
+ ((in[1] & 0x03) << 6) | ((in[2] & 0x3f)));
+ break;
+
+ case 4:
+ out += sprintf (out, "\\u%02x%02x%02x",
+ ((in[0] & 0x07) << 6) | ((in[1] & 0x3c) >> 2),
+ ((in[1] & 0x03) << 6) | ((in[2] & 0x3c) >> 2),
+ ((in[2] & 0x03) << 6) | ((in[3] & 0x3f)));
+ break;
+ default:
+ /* URG. */
+ break;
+ }
+
+ if (unicode_display == unicode_highlight && isatty (1))
+ out += sprintf (out, "\033[0m"); /* Default colour. */
+ break;
+
+ default:
+ /* URG */
+ break;
+ }
+
+ * consumed = nchars;
+ return out - orig_out;
+
+ invalid:
+ /* Not a valid UTF-8 sequence. */
+ *out = *in;
+ * consumed = 1;
+ return 1;
+}
+
/* Returns a version of IN with any control characters
replaced by escape sequences. Uses a static buffer
- if necessary. */
+ if necessary.
+
+ If unicode display is enabled, then also handles the
+ conversion of unicode characters. */
static const char *
sanitize_string (const char * in)
@@ -508,40 +636,50 @@ sanitize_string (const char * in)
of cases it will not be needed. */
do
{
- char c = *in++;
+ unsigned char c = *in++;
if (c == 0)
return original;
if (ISCNTRL (c))
break;
+
+ if (unicode_display != unicode_default && c >= 0xc0)
+ break;
}
while (1);
/* Copy the input, translating as needed. */
in = original;
- if (buffer_len < (strlen (in) * 2))
+ if (buffer_len < (strlen (in) * 9))
{
free ((void *) buffer);
- buffer_len = strlen (in) * 2;
+ buffer_len = strlen (in) * 9;
buffer = xmalloc (buffer_len + 1);
}
out = buffer;
do
{
- char c = *in++;
+ unsigned char c = *in++;
if (c == 0)
break;
- if (!ISCNTRL (c))
- *out++ = c;
- else
+ if (ISCNTRL (c))
{
*out++ = '^';
*out++ = c + 0x40;
}
+ else if (unicode_display != unicode_default && c >= 0xc0)
+ {
+ unsigned int num_consumed;
+
+ out += display_utf8 ((const unsigned char *)(in - 1), out, & num_consumed);
+ in += num_consumed - 1;
+ }
+ else
+ *out++ = c;
}
while (1);
@@ -4529,6 +4667,24 @@ dump_symbols (bfd *abfd ATTRIBUTE_UNUSED
free (alloc);
}
}
+ else if (unicode_display != unicode_default
+ && name != NULL && *name != '\0')
+ {
+ const char * sanitized_name;
+
+ /* If we want to sanitize the name, we do it here, and
+ temporarily clobber it while calling bfd_print_symbol.
+ FIXME: This is a gross hack. */
+ sanitized_name = sanitize_string (name);
+ if (sanitized_name != name)
+ (*current)->name = sanitized_name;
+ else
+ sanitized_name = NULL;
+ bfd_print_symbol (cur_bfd, stdout, *current,
+ bfd_print_symbol_all);
+ if (sanitized_name != NULL)
+ (*current)->name = name;
+ }
else
bfd_print_symbol (cur_bfd, stdout, *current,
bfd_print_symbol_all);
@@ -5212,7 +5368,7 @@ main (int argc, char **argv)
set_default_bfd_target ();
while ((c = getopt_long (argc, argv,
- "pP:ib:m:M:VvCdDlfFaHhrRtTxsSI:j:wE:zgeGW::",
+ "pP:ib:m:M:VvCdDlfFaHhrRtTU:xsSI:j:wE:zgeGW::",
long_options, (int *) 0))
!= EOF)
{
@@ -5495,6 +5651,23 @@ main (int argc, char **argv)
seenflag = true;
break;
+ case 'U':
+ if (streq (optarg, "default") || streq (optarg, "d"))
+ unicode_display = unicode_default;
+ else if (streq (optarg, "locale") || streq (optarg, "l"))
+ unicode_display = unicode_locale;
+ else if (streq (optarg, "escape") || streq (optarg, "e"))
+ unicode_display = unicode_escape;
+ else if (streq (optarg, "invalid") || streq (optarg, "i"))
+ unicode_display = unicode_invalid;
+ else if (streq (optarg, "hex") || streq (optarg, "x"))
+ unicode_display = unicode_hex;
+ else if (streq (optarg, "highlight") || streq (optarg, "h"))
+ unicode_display = unicode_highlight;
+ else
+ fatal (_("invalid argument to -U/--unicode: %s"), optarg);
+ break;
+
case 'H':
usage (stdout, 0);
/* No need to set seenflag or to break - usage() does not return. */
diff -rup binutils.orig/binutils/readelf.c binutils-2.37/binutils/readelf.c
--- binutils.orig/binutils/readelf.c 2022-03-10 10:52:01.063309505 +0000
+++ binutils-2.37/binutils/readelf.c 2022-03-10 10:52:09.781252724 +0000
@@ -4955,6 +4955,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 -rup binutils.orig/binutils/readelf.c.orig binutils-2.37/binutils/readelf.c.orig
--- binutils.orig/binutils/readelf.c.orig 2022-03-10 10:52:01.089309336 +0000
+++ binutils-2.37/binutils/readelf.c.orig 2022-03-10 10:51:55.396346413 +0000
@@ -328,6 +328,19 @@ typedef enum print_mode
}
print_mode;
+typedef enum unicode_display_type
+{
+ unicode_default = 0,
+ unicode_locale,
+ unicode_escape,
+ unicode_hex,
+ unicode_highlight,
+ unicode_invalid
+} unicode_display_type;
+
+static unicode_display_type unicode_display = unicode_default;
+
+
/* Versioned symbol info. */
enum versioned_symbol_info
{
@@ -632,11 +645,18 @@ print_symbol (signed int width, const ch
if (c == 0)
break;
- /* Do not print control characters directly as they can affect terminal
- settings. Such characters usually appear in the names generated
- by the assembler for local labels. */
- if (ISCNTRL (c))
+ if (ISPRINT (c))
{
+ putchar (c);
+ width_remaining --;
+ num_printed ++;
+ }
+ else if (ISCNTRL (c))
+ {
+ /* Do not print control characters directly as they can affect terminal
+ settings. Such characters usually appear in the names generated
+ by the assembler for local labels. */
+
if (width_remaining < 2)
break;
@@ -644,11 +664,137 @@ print_symbol (signed int width, const ch
width_remaining -= 2;
num_printed += 2;
}
- else if (ISPRINT (c))
+ else if (c == 0x7f)
{
- putchar (c);
- width_remaining --;
- num_printed ++;
+ if (width_remaining < 5)
+ break;
+ printf ("<DEL>");
+ width_remaining -= 5;
+ num_printed += 5;
+ }
+ else if (unicode_display != unicode_locale
+ && unicode_display != unicode_default)
+ {
+ /* Display unicode characters as something else. */
+ unsigned char bytes[4];
+ bool is_utf8;
+ uint nbytes;
+
+ bytes[0] = c;
+
+ if (bytes[0] < 0xc0)
+ {
+ nbytes = 1;
+ is_utf8 = false;
+ }
+ else
+ {
+ bytes[1] = *symbol++;
+
+ if ((bytes[1] & 0xc0) != 0x80)
+ {
+ is_utf8 = false;
+ /* Do not consume this character. It may only
+ be the first byte in the sequence that was
+ corrupt. */
+ --symbol;
+ nbytes = 1;
+ }
+ else if ((bytes[0] & 0x20) == 0)
+ {
+ is_utf8 = true;
+ nbytes = 2;
+ }
+ else
+ {
+ bytes[2] = *symbol++;
+
+ if ((bytes[2] & 0xc0) != 0x80)
+ {
+ is_utf8 = false;
+ symbol -= 2;
+ nbytes = 1;
+ }
+ else if ((bytes[0] & 0x10) == 0)
+ {
+ is_utf8 = true;
+ nbytes = 3;
+ }
+ else
+ {
+ bytes[3] = *symbol++;
+
+ nbytes = 4;
+
+ if ((bytes[3] & 0xc0) != 0x80)
+ {
+ is_utf8 = false;
+ symbol -= 3;
+ nbytes = 1;
+ }
+ else
+ is_utf8 = true;
+ }
+ }
+ }
+
+ if (unicode_display == unicode_invalid)
+ is_utf8 = false;
+
+ if (unicode_display == unicode_hex || ! is_utf8)
+ {
+ uint i;
+
+ if (width_remaining < (nbytes * 2) + 2)
+ break;
+
+ putchar (is_utf8 ? '<' : '{');
+ printf ("0x");
+ for (i = 0; i < nbytes; i++)
+ printf ("%02x", bytes[i]);
+ putchar (is_utf8 ? '>' : '}');
+ }
+ else
+ {
+ if (unicode_display == unicode_highlight && isatty (1))
+ printf ("\x1B[31;47m"); /* Red. */
+
+ switch (nbytes)
+ {
+ case 2:
+ if (width_remaining < 6)
+ break;
+ printf ("\\u%02x%02x",
+ (bytes[0] & 0x1c) >> 2,
+ ((bytes[0] & 0x03) << 6) | (bytes[1] & 0x3f));
+ break;
+ case 3:
+ if (width_remaining < 6)
+ break;
+ printf ("\\u%02x%02x",
+ ((bytes[0] & 0x0f) << 4) | ((bytes[1] & 0x3c) >> 2),
+ ((bytes[1] & 0x03) << 6) | (bytes[2] & 0x3f));
+ break;
+ case 4:
+ if (width_remaining < 8)
+ break;
+ printf ("\\u%02x%02x%02x",
+ ((bytes[0] & 0x07) << 6) | ((bytes[1] & 0x3c) >> 2),
+ ((bytes[1] & 0x03) << 6) | ((bytes[2] & 0x3c) >> 2),
+ ((bytes[2] & 0x03) << 6) | (bytes[3] & 0x3f));
+
+ break;
+ default:
+ /* URG. */
+ break;
+ }
+
+ if (unicode_display == unicode_highlight && isatty (1))
+ printf ("\033[0m"); /* Default colour. */
+ }
+
+ if (bytes[nbytes - 1] == 0)
+ break;
}
else
{
@@ -4668,6 +4814,7 @@ static struct option options[] =
{"syms", no_argument, 0, 's'},
{"silent-truncation",no_argument, 0, 'T'},
{"section-details", no_argument, 0, 't'},
+ {"unicode", required_argument, NULL, 'U'},
{"unwind", no_argument, 0, 'u'},
{"version-info", no_argument, 0, 'V'},
{"version", no_argument, 0, 'v'},
@@ -4744,6 +4891,12 @@ usage (FILE * stream)
fprintf (stream, _("\
--no-recurse-limit Disable a demangling recursion limit\n"));
fprintf (stream, _("\
+ -U[dlexhi] --unicode=[default|locale|escape|hex|highlight|invalid]\n\
+ Display unicode characters as determined by the current locale\n\
+ (default), escape sequences, \"<hex sequences>\", highlighted\n\
+ escape sequences, or treat them as invalid and display as\n\
+ \"{hex sequences}\"\n"));
+ fprintf (stream, _("\
-n --notes Display the core notes (if present)\n"));
fprintf (stream, _("\
-r --relocs Display the relocations (if present)\n"));
@@ -4928,7 +5081,7 @@ parse_args (struct dump_data *dumpdata,
usage (stderr);
while ((c = getopt_long
- (argc, argv, "ACDHILNPR:STVWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
+ (argc, argv, "ACDHILNPR:STU:VWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
{
switch (c)
{
@@ -5130,6 +5283,25 @@ parse_args (struct dump_data *dumpdata,
/* Ignored for backward compatibility. */
break;
+ case 'U':
+ if (optarg == NULL)
+ error (_("Missing arg to -U/--unicode")); /* Can this happen ? */
+ else if (streq (optarg, "default") || streq (optarg, "d"))
+ unicode_display = unicode_default;
+ else if (streq (optarg, "locale") || streq (optarg, "l"))
+ unicode_display = unicode_locale;
+ else if (streq (optarg, "escape") || streq (optarg, "e"))
+ unicode_display = unicode_escape;
+ else if (streq (optarg, "invalid") || streq (optarg, "i"))
+ unicode_display = unicode_invalid;
+ else if (streq (optarg, "hex") || streq (optarg, "x"))
+ unicode_display = unicode_hex;
+ else if (streq (optarg, "highlight") || streq (optarg, "h"))
+ unicode_display = unicode_highlight;
+ else
+ error (_("invalid argument to -U/--unicode: %s"), optarg);
+ break;
+
case OPTION_SYM_BASE:
sym_base = 0;
if (optarg != NULL)
@@ -5285,10 +5457,7 @@ process_file_header (Filedata * filedata
if (filedata->section_headers != NULL
&& header->e_phnum == PN_XNUM
&& filedata->section_headers[0].sh_info != 0)
- {
- header->e_phnum = filedata->section_headers[0].sh_info;
- printf (" (%u)", header->e_phnum);
- }
+ printf (" (%u)", filedata->section_headers[0].sh_info);
putc ('\n', stdout);
printf (_(" Size of section headers: %u (bytes)\n"),
header->e_shentsize);
@@ -5321,7 +5490,12 @@ process_file_header (Filedata * filedata
{
if (header->e_phnum == PN_XNUM
&& filedata->section_headers[0].sh_info != 0)
- header->e_phnum = filedata->section_headers[0].sh_info;
+ {
+ /* Throw away any cached read of PN_XNUM headers. */
+ free (filedata->program_headers);
+ filedata->program_headers = NULL;
+ header->e_phnum = filedata->section_headers[0].sh_info;
+ }
if (header->e_shnum == SHN_UNDEF)
header->e_shnum = filedata->section_headers[0].sh_size;
if (header->e_shstrndx == (SHN_XINDEX & 0xffff))
@@ -18873,6 +19047,8 @@ get_note_type (Filedata * filedata, unsi
return _("func");
case NT_GO_BUILDID:
return _("GO BUILDID");
+ case FDO_PACKAGING_METADATA:
+ return _("FDO_PACKAGING_METADATA");
default:
break;
}
@@ -20024,6 +20200,17 @@ print_stapsdt_note (Elf_Internal_Note *p
return false;
}
+static bool
+print_fdo_note (Elf_Internal_Note * pnote)
+{
+ if (pnote->descsz > 0 && pnote->type == FDO_PACKAGING_METADATA)
+ {
+ printf (_(" Packaging Metadata: %.*s\n"), (int) pnote->descsz, pnote->descdata);
+ return true;
+ }
+ return false;
+}
+
static const char *
get_ia64_vms_note_type (unsigned e_type)
{
@@ -20753,6 +20940,8 @@ process_note (Elf_Internal_Note * pnote
return print_stapsdt_note (pnote);
else if (startswith (pnote->namedata, "CORE"))
return print_core_note (pnote);
+ else if (startswith (pnote->namedata, "FDO"))
+ return print_fdo_note (pnote);
else if (((startswith (pnote->namedata, "GA")
&& strchr ("*$!+", pnote->namedata[2]) != NULL)
|| strchr ("*$!+", pnote->namedata[0]) != NULL)
diff -rup binutils.orig/binutils/testsuite/binutils-all/debuginfod.exp binutils-2.37/binutils/testsuite/binutils-all/debuginfod.exp
--- binutils.orig/binutils/testsuite/binutils-all/debuginfod.exp 2022-03-10 10:52:01.079309401 +0000
+++ binutils-2.37/binutils/testsuite/binutils-all/debuginfod.exp 2022-03-10 10:52:09.782252717 +0000
@@ -184,8 +184,14 @@ proc test_fetch_debugaltlink { prog prog
}
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)"
}
@@ -193,6 +199,12 @@ if { [regexp ".*DEBUGINFOD.*" $conf_objd
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)"
}

View file

@ -0,0 +1,459 @@
diff -rup binutils.orig/binutils/dwarf.c binutils-2.37/binutils/dwarf.c
--- binutils.orig/binutils/dwarf.c 2022-05-21 13:12:31.851174169 +0100
+++ binutils-2.37/binutils/dwarf.c 2022-05-21 13:12:58.798988551 +0100
@@ -11533,7 +11533,11 @@ free_debug_memory (void)
free_dwo_info ();
}
-void
+/* Enable display of specific DWARF sections as determined by the comma
+ separated strings in NAMES. Returns non-zero if any displaying was
+ enabled. */
+
+int
dwarf_select_sections_by_names (const char *names)
{
typedef struct
@@ -11586,6 +11590,7 @@ dwarf_select_sections_by_names (const ch
};
const char *p;
+ int result = 0;
p = names;
while (*p)
@@ -11600,6 +11605,7 @@ dwarf_select_sections_by_names (const ch
&& (p[len] == ',' || p[len] == '\0'))
{
* entry->variable = entry->val;
+ result |= entry->val;
/* The --debug-dump=frames-interp option also
enables the --debug-dump=frames option. */
@@ -11622,48 +11628,82 @@ dwarf_select_sections_by_names (const ch
if (*p == ',')
p++;
}
+
+ return result;
}
-void
+/* Enable display of specific DWARF sections as determined by the characters
+ in LETTERS. Returns non-zero if any displaying was enabled. */
+
+int
dwarf_select_sections_by_letters (const char *letters)
{
- unsigned int lindex = 0;
+ typedef struct
+ {
+ const char letter;
+ int * variable;
+ int val;
+ bool cont;
+ }
+ debug_dump_letter_opts;
- while (letters[lindex])
- switch (letters[lindex++])
- {
- case 'A': do_debug_addr = 1; break;
- case 'a': do_debug_abbrevs = 1; break;
- case 'c': do_debug_cu_index = 1; break;
+ static const debug_dump_letter_opts letter_table [] =
+ {
+ { 'A', & do_debug_addr, 1, false},
+ { 'a', & do_debug_abbrevs, 1, false },
+ { 'c', & do_debug_cu_index, 1, false },
#ifdef HAVE_LIBDEBUGINFOD
- case 'D': use_debuginfod = 1; break;
- case 'E': use_debuginfod = 0; break;
+ { 'D', & use_debuginfod, 1, false },
+ { 'E', & use_debuginfod, 0, false },
#endif
- case 'F': do_debug_frames_interp = 1; /* Fall through. */
- case 'f': do_debug_frames = 1; break;
- case 'g': do_gdb_index = 1; break;
- case 'i': do_debug_info = 1; break;
- case 'K': do_follow_links = 1; break;
- case 'N': do_follow_links = 0; break;
- case 'k': do_debug_links = 1; break;
- case 'l': do_debug_lines |= FLAG_DEBUG_LINES_RAW; break;
- case 'L': do_debug_lines |= FLAG_DEBUG_LINES_DECODED; break;
- case 'm': do_debug_macinfo = 1; break;
- case 'O': do_debug_str_offsets = 1; break;
- case 'o': do_debug_loc = 1; break;
- case 'p': do_debug_pubnames = 1; break;
- case 'R': do_debug_ranges = 1; break;
- case 'r': do_debug_aranges = 1; break;
- case 's': do_debug_str = 1; break;
- case 'T': do_trace_aranges = 1; break;
- case 't': do_debug_pubtypes = 1; break;
- case 'U': do_trace_info = 1; break;
- case 'u': do_trace_abbrevs = 1; break;
-
- default:
- warn (_("Unrecognized debug option '%s'\n"), letters);
- break;
- }
+ { 'F', & do_debug_frames_interp, 1, true }, /* Note the fall through. */
+ { 'f', & do_debug_frames, 1, false },
+ { 'g', & do_gdb_index, 1, false },
+ { 'i', & do_debug_info, 1, false },
+ { 'K', & do_follow_links, 1, false },
+ { 'k', & do_debug_links, 1, false },
+ { 'L', & do_debug_lines, FLAG_DEBUG_LINES_DECODED, false },
+ { 'l', & do_debug_lines, FLAG_DEBUG_LINES_RAW, false },
+ { 'm', & do_debug_macinfo, 1, false },
+ { 'N', & do_follow_links, 0, false },
+ { 'O', & do_debug_str_offsets, 1, false },
+ { 'o', & do_debug_loc, 1, false },
+ { 'p', & do_debug_pubnames, 1, false },
+ { 'R', & do_debug_ranges, 1, false },
+ { 'r', & do_debug_aranges, 1, false },
+ { 's', & do_debug_str, 1, false },
+ { 'T', & do_trace_aranges, 1, false },
+ { 't', & do_debug_pubtypes, 1, false },
+ { 'U', & do_trace_info, 1, false },
+ { 'u', & do_trace_abbrevs, 1, false },
+ { 0, NULL, 0, false }
+ };
+
+ int result = 0;
+
+ while (* letters)
+ {
+ const debug_dump_letter_opts * entry;
+
+ for (entry = letter_table; entry->letter; entry++)
+ {
+ if (entry->letter == * letters)
+ {
+ * entry->variable |= entry->val;
+ result |= entry->val;
+
+ if (! entry->cont)
+ break;
+ }
+ }
+
+ if (entry->letter == 0)
+ warn (_("Unrecognized debug letter option '%c'\n"), * letters);
+
+ letters ++;
+ }
+
+ return result;
}
void
Only in binutils-2.37/binutils/: dwarf.c.orig
diff -rup binutils.orig/binutils/dwarf.h binutils-2.37/binutils/dwarf.h
--- binutils.orig/binutils/dwarf.h 2022-05-21 13:12:31.854174148 +0100
+++ binutils-2.37/binutils/dwarf.h 2022-05-21 13:12:58.799988544 +0100
@@ -243,8 +243,8 @@ extern void *open_debug_file (const char
extern void free_debug_memory (void);
-extern void dwarf_select_sections_by_names (const char *);
-extern void dwarf_select_sections_by_letters (const char *);
+extern int dwarf_select_sections_by_names (const char *);
+extern int dwarf_select_sections_by_letters (const char *);
extern void dwarf_select_sections_all (void);
extern unsigned int * find_cu_tu_set (void *, unsigned int);
Only in binutils-2.37/binutils/: dwarf.h.orig
diff -rup binutils.orig/binutils/objdump.c binutils-2.37/binutils/objdump.c
--- binutils.orig/binutils/objdump.c 2022-05-21 13:12:31.855174141 +0100
+++ binutils-2.37/binutils/objdump.c 2022-05-21 13:14:42.740372795 +0100
@@ -5010,6 +5010,26 @@ sign_extend_address (bfd *abfd ATTRIBUTE
return (((vma & ((mask << 1) - 1)) ^ mask) - mask);
}
+static bool
+might_need_separate_debug_info (bool is_mainfile)
+{
+ /* We do not follow links from debug info files. */
+ if (! is_mainfile)
+ return false;
+
+ /* Since do_follow_links might be enabled by default, only treat it as an
+ indication that separate files should be loaded if setting it was a
+ deliberate user action. */
+ if (DEFAULT_FOR_FOLLOW_LINKS == 0 && do_follow_links)
+ return true;
+
+ if (process_links || dump_symtab || dump_debugging
+ || dump_dwarf_section_info)
+ return true;
+
+ return false;
+}
+
/* Dump selected contents of ABFD. */
static void
@@ -5024,16 +5044,8 @@ dump_bfd (bfd *abfd, bool is_mainfile)
else
byte_get = NULL;
- /* Load any separate debug information files.
- We do this now and without checking do_follow_links because separate
- debug info files may contain symbol tables that we will need when
- displaying information about the main file. Any memory allocated by
- load_separate_debug_files will be released when we call
- free_debug_memory below.
-
- The test on is_mainfile is there because the chain of separate debug
- info files is a global variable shared by all invocations of dump_bfd. */
- if (is_mainfile)
+ /* Load any separate debug information files. */
+ if (byte_get != NULL && might_need_separate_debug_info (is_mainfile))
{
load_separate_debug_files (abfd, bfd_get_filename (abfd));
@@ -5588,20 +5600,30 @@ main (int argc, char **argv)
do_follow_links = true;
break;
case 'W':
- dump_dwarf_section_info = true;
seenflag = true;
if (optarg)
- dwarf_select_sections_by_letters (optarg);
+ {
+ if (dwarf_select_sections_by_letters (optarg))
+ dump_dwarf_section_info = true;
+ }
else
- dwarf_select_sections_all ();
+ {
+ dump_dwarf_section_info = true;
+ dwarf_select_sections_all ();
+ }
break;
case OPTION_DWARF:
- dump_dwarf_section_info = true;
seenflag = true;
if (optarg)
- dwarf_select_sections_by_names (optarg);
+ {
+ if (dwarf_select_sections_by_names (optarg))
+ dump_dwarf_section_info = true;
+ }
else
- dwarf_select_sections_all ();
+ {
+ dwarf_select_sections_all ();
+ dump_dwarf_section_info = true;
+ }
break;
case OPTION_DWARF_DEPTH:
{
diff -rup binutils.orig/binutils/objdump.c.orig binutils-2.37/binutils/objdump.c.orig
--- binutils.orig/binutils/objdump.c.orig 2022-05-21 13:12:31.872174024 +0100
+++ binutils-2.37/binutils/objdump.c.orig 2022-05-21 13:12:22.066241569 +0100
@@ -280,6 +280,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 -rup binutils.orig/binutils/objdump.c.rej binutils-2.37/binutils/objdump.c.rej
--- binutils.orig/binutils/objdump.c.rej 2022-05-21 13:12:31.872174024 +0100
+++ binutils-2.37/binutils/objdump.c.rej 2022-05-21 13:12:58.800988538 +0100
@@ -1,43 +1,21 @@
---- binutils/objdump.c
-+++ binutils/objdump.c
-@@ -487,28 +517,16 @@ static struct option long_options[]=
- {"source", no_argument, NULL, 'S'},
- {"source-comment", optional_argument, NULL, OPTION_SOURCE_COMMENT},
- {"special-syms", no_argument, &dump_special_syms, 1},
-- {"include", required_argument, NULL, 'I'},
-- {"dwarf", optional_argument, NULL, OPTION_DWARF},
--#ifdef ENABLE_LIBCTF
-- {"ctf", optional_argument, NULL, OPTION_CTF},
-- {"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT},
--#endif
- {"stabs", no_argument, NULL, 'G'},
- {"start-address", required_argument, NULL, OPTION_START_ADDRESS},
- {"stop-address", required_argument, NULL, OPTION_STOP_ADDRESS},
- {"syms", no_argument, NULL, 't'},
- {"target", required_argument, NULL, 'b'},
-+ {"unicode", required_argument, NULL, 'U'},
- {"version", no_argument, NULL, 'V'},
-- {"wide", no_argument, NULL, 'w'},
-- {"prefix", required_argument, NULL, OPTION_PREFIX},
-- {"prefix-strip", required_argument, NULL, OPTION_PREFIX_STRIP},
-- {"insn-width", required_argument, NULL, OPTION_INSN_WIDTH},
-- {"dwarf-depth", required_argument, 0, OPTION_DWARF_DEPTH},
-- {"dwarf-start", required_argument, 0, OPTION_DWARF_START},
-- {"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK},
-- {"inlines", no_argument, 0, OPTION_INLINES},
- {"visualize-jumps", optional_argument, 0, OPTION_VISUALIZE_JUMPS},
-- {0, no_argument, 0, 0}
-+ {"wide", no_argument, NULL, 'w'},
-+ {NULL, no_argument, NULL, 0}
- };
-
- static void
-@@ -5375,7 +5533,7 @@ main (int argc, char **argv)
- set_default_bfd_target ();
+--- binutils/objdump.c 2022-05-20 16:57:16.566961359 +0100
++++ binutils/objdump.c 2022-05-20 16:57:32.881853688 +0100
+@@ -5042,16 +5062,8 @@ dump_bfd (bfd *abfd, bool is_mainfile)
+ else
+ byte_get = NULL;
- while ((c = getopt_long (argc, argv,
-- "CDE:FGHI:LM:P:RSTVW::ab:defghij:lm:prstvwxz",
-+ "CDE:FGHI:LM:P:RSTU:VW::ab:defghij:lm:prstvwxz",
- long_options, (int *) 0))
- != EOF)
+- /* Load any separate debug information files.
+- We do this now and without checking do_follow_links because separate
+- debug info files may contain symbol tables that we will need when
+- displaying information about the main file. Any memory allocated by
+- load_separate_debug_files will be released when we call
+- free_debug_memory below.
+-
+- The test on is_mainfile is there because the chain of separate debug
+- info files is a global variable shared by all invocations of dump_bfd. */
+- if (byte_get != NULL && is_mainfile)
++ /* Load any separate debug information files. */
++ if (byte_get != NULL && might_need_separate_debug_info (is_mainfile))
{
+ load_separate_debug_files (abfd, bfd_get_filename (abfd));
+
diff -rup binutils.orig/binutils/readelf.c binutils-2.37/binutils/readelf.c
--- binutils.orig/binutils/readelf.c 2022-05-21 13:12:31.853174155 +0100
+++ binutils-2.37/binutils/readelf.c 2022-05-21 13:12:58.802988523 +0100
@@ -21632,6 +21632,26 @@ initialise_dump_sects (Filedata * fileda
}
}
+static bool
+might_need_separate_debug_info (Filedata * filedata)
+{
+ /* Debuginfo files do not need further separate file loading. */
+ if (filedata->file_header.e_shstrndx == SHN_UNDEF)
+ return false;
+
+ /* Since do_follow_links might be enabled by default, only treat it as an
+ indication that separate files should be loaded if setting it was a
+ deliberate user action. */
+ if (DEFAULT_FOR_FOLLOW_LINKS == 0 && do_follow_links)
+ return true;
+
+ if (process_links || do_syms || do_unwind
+ || do_dump || do_debugging)
+ return true;
+
+ return false;
+}
+
/* Process one ELF object file according to the command line options.
This file may actually be stored in an archive. The file is
positioned at the start of the ELF object. Returns TRUE if no
@@ -21715,7 +21735,7 @@ process_object (Filedata * filedata)
if (! process_version_sections (filedata))
res = false;
- if (filedata->file_header.e_shstrndx != SHN_UNDEF)
+ if (might_need_separate_debug_info (filedata))
have_separate_files = load_separate_debug_files (filedata, filedata->file_name);
else
have_separate_files = false;
diff -rup binutils.orig/binutils/readelf.c.orig binutils-2.37/binutils/readelf.c.orig
--- binutils.orig/binutils/readelf.c.orig 2022-05-21 13:12:31.854174148 +0100
+++ binutils-2.37/binutils/readelf.c.orig 2022-05-21 13:12:22.077241494 +0100
@@ -4955,6 +4955,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 -rup binutils.orig/binutils/testsuite/binutils-all/debuginfod.exp binutils-2.37/binutils/testsuite/binutils-all/debuginfod.exp
--- binutils.orig/binutils/testsuite/binutils-all/debuginfod.exp 2022-05-21 13:12:31.872174024 +0100
+++ binutils-2.37/binutils/testsuite/binutils-all/debuginfod.exp 2022-05-21 13:12:58.803988517 +0100
@@ -188,7 +188,7 @@ if { [regexp ".*DEBUGINFOD.*" $conf_objd
test_fetch_debugaltlink $OBJDUMP "-Wk"
set test "disabling debuginfod access"
- setup_xfail *-*-*
+ # setup_xfail *-*-*
test_fetch_debuglink $OBJDUMP "-W -WE"
set test "debuginfod"
@@ -201,7 +201,7 @@ if { [regexp ".*DEBUGINFOD.*" $conf_read
test_fetch_debugaltlink $READELF "-wk"
set test "disabling debuginfod access"
- setup_xfail *-*-*
+ # setup_xfail *-*-*
test_fetch_debuglink $READELF "-w -wE"
set test "debuginfod"
Only in binutils-2.37/binutils/testsuite/binutils-all: debuginfod.exp.orig
diff -rup binutils.orig/binutils/testsuite/binutils-all/objdump.Wk binutils-2.37/binutils/testsuite/binutils-all/objdump.Wk
--- binutils.orig/binutils/testsuite/binutils-all/objdump.Wk 2022-05-21 13:12:31.862174093 +0100
+++ binutils-2.37/binutils/testsuite/binutils-all/objdump.Wk 2022-05-21 13:12:58.803988517 +0100
@@ -1,8 +1,9 @@
+#...
tmpdir/debuglink\.o: file format .*
-Contents of the \.gnu_debuglink section:
+Contents of the \.gnu_debuglink section.*
Separate debug info file: this_is_a_debuglink\.debug
CRC value: 0x12345678
-Contents of the \.gnu_debugaltlink section:
+Contents of the \.gnu_debugaltlink section.*
Separate debug info file: linkdebug\.debug
Build-ID \(0x18 bytes\):
00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 01 23 45 67 89 ab cd ef
diff -rup binutils.orig/binutils/testsuite/binutils-all/readelf.k binutils-2.37/binutils/testsuite/binutils-all/readelf.k
--- binutils.orig/binutils/testsuite/binutils-all/readelf.k 2022-05-21 13:12:31.863174086 +0100
+++ binutils-2.37/binutils/testsuite/binutils-all/readelf.k 2022-05-21 13:12:58.812988455 +0100
@@ -1,7 +1,8 @@
-Contents of the \.gnu_debuglink section:
+#...
+Contents of the \.gnu_debuglink section.*
Separate debug info file: this_is_a_debuglink\.debug
CRC value: 0x12345678
-Contents of the \.gnu_debugaltlink section:
+Contents of the \.gnu_debugaltlink section.*
Separate debug info file: linkdebug\.debug
Build-ID \(0x18 bytes\):
00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 01 23 45 67 89 ab cd ef
Only in binutils-2.37/binutils/testsuite/binutils-all: debuginfod.exp.orig
--- binutils.orig/binutils/dwarf.c 2022-06-30 15:28:53.484593360 +0100
+++ binutils-2.37/binutils/dwarf.c 2022-06-30 15:32:22.112213811 +0100
@@ -11689,7 +11689,10 @@ dwarf_select_sections_by_letters (const
{
if (entry->letter == * letters)
{
- * entry->variable |= entry->val;
+ if (entry->val == 0)
+ * entry->variable = 0;
+ else
+ * entry->variable |= entry->val;
result |= entry->val;
if (! entry->cont)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,29 @@
diff -rup binutils.orig/binutils/readelf.c binutils-2.37/binutils/readelf.c
--- binutils.orig/binutils/readelf.c 2022-02-10 10:10:21.508156583 +0000
+++ binutils-2.37/binutils/readelf.c 2022-02-10 10:13:36.486511842 +0000
@@ -5457,10 +5457,7 @@ process_file_header (Filedata * filedata
if (filedata->section_headers != NULL
&& header->e_phnum == PN_XNUM
&& filedata->section_headers[0].sh_info != 0)
- {
- header->e_phnum = filedata->section_headers[0].sh_info;
- printf (" (%u)", header->e_phnum);
- }
+ printf (" (%u)", filedata->section_headers[0].sh_info);
putc ('\n', stdout);
printf (_(" Size of section headers: %u (bytes)\n"),
header->e_shentsize);
@@ -5493,7 +5490,12 @@ process_file_header (Filedata * filedata
{
if (header->e_phnum == PN_XNUM
&& filedata->section_headers[0].sh_info != 0)
- header->e_phnum = filedata->section_headers[0].sh_info;
+ {
+ /* Throw away any cached read of PN_XNUM headers. */
+ free (filedata->program_headers);
+ filedata->program_headers = NULL;
+ header->e_phnum = filedata->section_headers[0].sh_info;
+ }
if (header->e_shnum == SHN_UNDEF)
header->e_shnum = filedata->section_headers[0].sh_size;
if (header->e_shstrndx == (SHN_XINDEX & 0xffff))

View file

@ -0,0 +1,29 @@
--- binutils.orig/binutils/readelf.c 2022-10-03 13:20:42.707527855 +0100
+++ binutils-2.39/binutils/readelf.c 2022-10-03 13:21:25.785436781 +0100
@@ -6357,6 +6357,13 @@ get_32bit_section_headers (Filedata * fi
/* PR binutils/17531: Cope with unexpected section header sizes. */
if (size == 0 || num == 0)
return false;
+
+ /* The section header cannot be at the start of the file - that is
+ where the ELF file header is located. A file with absolutely no
+ sections in it will use a shoff of 0. */
+ if (filedata->file_header.e_shoff == 0)
+ return false;
+
if (size < sizeof * shdrs)
{
if (! probe)
@@ -6421,6 +6428,12 @@ get_64bit_section_headers (Filedata * fi
if (size == 0 || num == 0)
return false;
+ /* The section header cannot be at the start of the file - that is
+ where the ELF file header is located. A file with absolutely no
+ sections in it will use a shoff of 0. */
+ if (filedata->file_header.e_shoff == 0)
+ return false;
+
if (size < sizeof * shdrs)
{
if (! probe)

View file

@ -0,0 +1,184 @@
From 30cbd32aec30b4bc13427bbd87c4c63c739d4578 Mon Sep 17 00:00:00 2001
From: Steiner H Gunderson <steinar+sourceware@gunderson.no>
Date: Mon, 21 Mar 2022 14:29:12 +0000
Subject: [PATCH] Reduce O(n2) performance overhead when parsing DWARF unit
information.
PR 28978
* dwarf2.c (scan_unit_for_symbols): When performing second pass,
check to see if the function or variable being processed is the
same as the previous one.
---
bfd/ChangeLog | 7 ++++
bfd/dwarf2.c | 93 +++++++++++++++++++++++++++++++++------------------
2 files changed, 67 insertions(+), 33 deletions(-)
//diff --git a/bfd/ChangeLog b/bfd/ChangeLog
//index 6ac8b96c57a..fcf5abad5a1 100644
//--- a/bfd/ChangeLog
//+++ b/bfd/ChangeLog
//@@ -1,3 +1,10 @@
//+2022-03-21 Steiner H Gunderson <steinar+sourceware@gunderson.no>
//+
//+ PR 28978
//+ * dwarf2.c (scan_unit_for_symbols): When performing second pass,
//+ check to see if the function or variable being processed is the
//+ same as the previous one.
//+
2022-03-18 Viorel Preoteasa <viorel.preoteasa@gmail.com>
PR 28924
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index fdf071c36e9..bb176798f9a 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -3293,6 +3293,36 @@ lookup_var_by_offset (bfd_uint64_t offset, struct varinfo * table)
/* DWARF2 Compilation unit functions. */
+static struct funcinfo *
+reverse_funcinfo_list (struct funcinfo *head)
+{
+ struct funcinfo *rhead;
+ struct funcinfo *temp;
+
+ for (rhead = NULL; head; head = temp)
+ {
+ temp = head->prev_func;
+ head->prev_func = rhead;
+ rhead = head;
+ }
+ return rhead;
+}
+
+static struct varinfo *
+reverse_varinfo_list (struct varinfo *head)
+{
+ struct varinfo *rhead;
+ struct varinfo *temp;
+
+ for (rhead = NULL; head; head = temp)
+ {
+ temp = head->prev_var;
+ head->prev_var = rhead;
+ rhead = head;
+ }
+ return rhead;
+}
+
/* Scan over each die in a comp. unit looking for functions to add
to the function table and variables to the variable table. */
@@ -3308,7 +3338,9 @@ scan_unit_for_symbols (struct comp_unit *unit)
struct funcinfo *func;
} *nested_funcs;
int nested_funcs_size;
-
+ struct funcinfo *last_func;
+ struct varinfo *last_var;
+
/* Maintain a stack of in-scope functions and inlined functions, which we
can use to set the caller_func field. */
nested_funcs_size = 32;
@@ -3442,10 +3474,16 @@ scan_unit_for_symbols (struct comp_unit *unit)
}
}
+ unit->function_table = reverse_funcinfo_list (unit->function_table);
+ unit->variable_table = reverse_varinfo_list (unit->variable_table);
+
/* This is the second pass over the abbrevs. */
info_ptr = unit->first_child_die_ptr;
nesting_level = 0;
+ last_func = NULL;
+ last_var = NULL;
+
while (nesting_level >= 0)
{
unsigned int abbrev_number, i;
@@ -3481,16 +3519,32 @@ scan_unit_for_symbols (struct comp_unit *unit)
|| abbrev->tag == DW_TAG_entry_point
|| abbrev->tag == DW_TAG_inlined_subroutine)
{
- func = lookup_func_by_offset (current_offset, unit->function_table);
+ if (last_func
+ && last_func->prev_func
+ && last_func->prev_func->unit_offset == current_offset)
+ func = last_func->prev_func;
+ else
+ func = lookup_func_by_offset (current_offset, unit->function_table);
+
if (func == NULL)
goto fail;
+
+ last_func = func;
}
else if (abbrev->tag == DW_TAG_variable
|| abbrev->tag == DW_TAG_member)
{
- var = lookup_var_by_offset (current_offset, unit->variable_table);
+ if (last_var
+ && last_var->prev_var
+ && last_var->prev_var->unit_offset == current_offset)
+ var = last_var->prev_var;
+ else
+ var = lookup_var_by_offset (current_offset, unit->variable_table);
+
if (var == NULL)
goto fail;
+
+ last_var = var;
}
for (i = 0; i < abbrev->num_attrs; ++i)
@@ -3684,6 +3738,9 @@ scan_unit_for_symbols (struct comp_unit *unit)
}
}
+ unit->function_table = reverse_funcinfo_list (unit->function_table);
+ unit->variable_table = reverse_varinfo_list (unit->variable_table);
+
free (nested_funcs);
return true;
@@ -4047,36 +4104,6 @@ comp_unit_find_line (struct comp_unit *unit,
linenumber_ptr);
}
-static struct funcinfo *
-reverse_funcinfo_list (struct funcinfo *head)
-{
- struct funcinfo *rhead;
- struct funcinfo *temp;
-
- for (rhead = NULL; head; head = temp)
- {
- temp = head->prev_func;
- head->prev_func = rhead;
- rhead = head;
- }
- return rhead;
-}
-
-static struct varinfo *
-reverse_varinfo_list (struct varinfo *head)
-{
- struct varinfo *rhead;
- struct varinfo *temp;
-
- for (rhead = NULL; head; head = temp)
- {
- temp = head->prev_var;
- head->prev_var = rhead;
- rhead = head;
- }
- return rhead;
-}
-
/* Extract all interesting funcinfos and varinfos of a compilation
unit into hash tables for faster lookup. Returns TRUE if no
errors were enountered; FALSE otherwise. */
--
2.37.2

View file

@ -0,0 +1,48 @@
diff -rup binutils.orig/bfd/elf.c binutils-2.37/bfd/elf.c
--- binutils.orig/bfd/elf.c 2023-03-30 15:32:51.853932063 +0100
+++ binutils-2.37/bfd/elf.c 2023-03-30 15:34:02.346807048 +0100
@@ -3928,15 +3928,23 @@ assign_section_numbers (bfd *abfd, struc
{
case SHT_REL:
case SHT_RELA:
- /* A reloc section which we are treating as a normal BFD
- section. sh_link is the section index of the symbol
- table. sh_info is the section index of the section to
- which the relocation entries apply. We assume that an
- allocated reloc section uses the dynamic symbol table.
- FIXME: How can we be sure? */
- s = bfd_get_section_by_name (abfd, ".dynsym");
- if (s != NULL)
- d->this_hdr.sh_link = elf_section_data (s)->this_idx;
+ /* sh_link is the section index of the symbol table.
+ sh_info is the section index of the section to which the
+ relocation entries apply. */
+ if (d->this_hdr.sh_link == 0)
+ {
+ /* FIXME maybe: If this is a reloc section which we are
+ treating as a normal section then we likely should
+ not be assuming its sh_link is .dynsym or .symtab. */
+ if ((sec->flags & SEC_ALLOC) != 0)
+ {
+ s = bfd_get_section_by_name (abfd, ".dynsym");
+ if (s != NULL)
+ d->this_hdr.sh_link = elf_section_data (s)->this_idx;
+ }
+ else
+ d->this_hdr.sh_link = elf_onesymtab (abfd);
+ }
s = elf_get_reloc_section (sec);
if (s != NULL)
diff -rup binutils.orig/binutils/objcopy.c binutils-2.37/binutils/objcopy.c
--- binutils.orig/binutils/objcopy.c 2023-03-30 15:32:50.801933929 +0100
+++ binutils-2.37/binutils/objcopy.c 2023-03-30 15:34:26.746764718 +0100
@@ -2219,7 +2219,7 @@ merge_gnu_build_notes (bfd * ab
{
if (pnote->note.namedata[4] == '2')
++ version_2_seen;
- else if (pnote->note.namedata[4] == '3')
+ else if (pnote->note.namedata[4] == '3' || pnote->note.namedata[4] == '4')
++ version_3_seen;
else
{

View file

@ -0,0 +1,142 @@
diff -rup binutils.orig/bfd/elf64-s390.c binutils-2.37/bfd/elf64-s390.c
--- binutils.orig/bfd/elf64-s390.c 2022-05-19 11:32:09.424050559 +0100
+++ binutils-2.37/bfd/elf64-s390.c 2022-05-19 11:32:29.169924728 +0100
@@ -774,7 +774,7 @@ elf_s390_tls_transition (struct bfd_link
int r_type,
int is_local)
{
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
return r_type;
switch (r_type)
@@ -1026,7 +1026,7 @@ elf_s390_check_relocs (bfd *abfd,
case R_390_TLS_GOTIE20:
case R_390_TLS_GOTIE64:
case R_390_TLS_IEENT:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
info->flags |= DF_STATIC_TLS;
/* Fall through */
@@ -1107,7 +1107,7 @@ elf_s390_check_relocs (bfd *abfd,
if (r_type == R_390_TLS_LE64 && bfd_link_pie (info))
break;
- if (!bfd_link_pic (info))
+ if (!bfd_link_dll (info))
break;
info->flags |= DF_STATIC_TLS;
/* Fall through */
@@ -1571,7 +1571,7 @@ allocate_dynrelocs (struct elf_link_hash
to R_390_TLS_LE64 requiring no TLS entry. For GOTIE12 and IEENT
we can save the dynamic TLS relocation. */
if (h->got.refcount > 0
- && !bfd_link_pic (info)
+ && !bfd_link_dll (info)
&& h->dynindx == -1
&& elf_s390_hash_entry(h)->tls_type >= GOT_TLS_IE)
{
@@ -1876,7 +1876,20 @@ elf_s390_size_dynamic_sections (bfd *out
else if (startswith (bfd_section_name (s), ".rela"))
{
if (s->size != 0 && s != htab->elf.srelplt)
- relocs = true;
+ {
+ relocs = true;
+ if (s == htab->elf.irelplt)
+ {
+ /* In static-pie case, there are IRELATIVE-relocs in
+ .rela.iplt (htab->irelplt), which will later be grouped
+ to .rela.plt. On s390, the IRELATIVE relocations are
+ always located in .rela.iplt - even for non-static case.
+ Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added
+ to the dynamic section even if htab->srelplt->size == 0.
+ See _bfd_elf_add_dynamic_tags in bfd/elflink.c. */
+ htab->elf.dt_jmprel_required = true;
+ }
+ }
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
@@ -2662,7 +2675,7 @@ elf_s390_relocate_section (bfd *output_b
/* Relocations for tls literal pool entries. */
case R_390_TLS_IE64:
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
{
Elf_Internal_Rela outrel;
asection *sreloc;
@@ -2690,7 +2703,7 @@ elf_s390_relocate_section (bfd *output_b
else if (h != NULL)
{
tls_type = elf_s390_hash_entry(h)->tls_type;
- if (!bfd_link_pic (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE)
+ if (!bfd_link_dll (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE)
r_type = R_390_TLS_LE64;
}
if (r_type == R_390_TLS_GD64 && tls_type >= GOT_TLS_IE)
@@ -2801,14 +2814,14 @@ elf_s390_relocate_section (bfd *output_b
if (local_got_offsets == NULL)
abort();
off = local_got_offsets[r_symndx];
- if (bfd_link_pic (info))
+ if (bfd_link_dll (info))
goto emit_tls_relocs;
}
else
{
off = h->got.offset;
tls_type = elf_s390_hash_entry(h)->tls_type;
- if (bfd_link_pic (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE)
+ if (bfd_link_dll (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE)
goto emit_tls_relocs;
}
@@ -2825,7 +2838,7 @@ elf_s390_relocate_section (bfd *output_b
break;
case R_390_TLS_LDM64:
- if (! bfd_link_pic (info))
+ if (! bfd_link_dll (info))
/* The literal pool entry this relocation refers to gets ignored
by the optimized code of the local exec model. Do nothing
and the value will turn out zero. */
@@ -2900,7 +2913,7 @@ elf_s390_relocate_section (bfd *output_b
continue;
case R_390_TLS_LDO64:
- if (bfd_link_pic (info) || (input_section->flags & SEC_DEBUGGING))
+ if (bfd_link_dll (info) || (input_section->flags & SEC_DEBUGGING))
relocation -= dtpoff_base (info);
else
/* When converting LDO to LE, we must negate. */
@@ -2922,7 +2935,7 @@ elf_s390_relocate_section (bfd *output_b
if (r_type == R_390_TLS_LOAD)
{
- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
+ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1))
{
/* IE->LE transition. Four valid cases:
lg %rx,(0,%ry) -> sllg %rx,%ry,0
@@ -2972,7 +2985,7 @@ elf_s390_relocate_section (bfd *output_b
invalid_tls_insn (input_bfd, input_section, rel);
return false;
}
- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
+ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1))
{
/* GD->LE transition.
brasl %r14,__tls_get_addr@plt -> brcl 0,. */
@@ -2991,7 +3004,7 @@ elf_s390_relocate_section (bfd *output_b
}
else if (r_type == R_390_TLS_LDCALL)
{
- if (!bfd_link_pic (info))
+ if (!bfd_link_dll (info))
{
unsigned int insn0, insn1;
Only in binutils-2.37/bfd: elf64-s390.c.orig

View file

@ -0,0 +1,49 @@
From 0d62064867c74286360e821b75ef6799bedc4b34 Mon Sep 17 00:00:00 2001
From: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Date: Tue, 28 Sep 2021 20:11:26 +0930
Subject: [PATCH] PR28391, strip/objcopy --preserve-dates *.a: cannot set time
After commit 985e0264516 copy_archive function began to pass invalid
values to the utimensat(2) function when it tries to preserve
timestamps in ar archives. This happens because the bfd_stat_arch_elt
implementation for ar archives fills only the st_mtim.tv_sec part of
the st_mtim timespec structure, but leaves the st_mtim.tv_nsec part
and the whole st_atim timespec untouched leaving them uninitialized
PR 28391
* ar.c (extract_file): Clear buf for preserve_dates.
* objcopy.c (copy_archive): Likewise.
---
binutils/ar.c | 3 +++
binutils/objcopy.c | 1 +
2 files changed, 4 insertions(+)
diff --git a/binutils/ar.c b/binutils/ar.c
index 5d6976c7027..8885585ef75 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -1180,6 +1180,9 @@ extract_file (bfd *abfd)
bfd_size_type size;
struct stat buf;
+ if (preserve_dates)
+ memset (&buf, 0, sizeof (buf));
+
if (bfd_stat_arch_elt (abfd, &buf) != 0)
/* xgettext:c-format */
fatal (_("internal stat error on %s"), bfd_get_filename (abfd));
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index a6c2e0dcc26..fd7557fe433 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3600,6 +3600,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
if (preserve_dates)
{
+ memset (&buf, 0, sizeof (buf));
stat_status = bfd_stat_arch_elt (this_element, &buf);
if (stat_status != 0)
--
2.37.1

View file

@ -0,0 +1,30 @@
Only in binutils-2.37: binutils-update-linker-manual.patch
Only in binutils-2.37/ld: binutils-update-linker-manual.patch
Only in binutils-2.37/ld: ld.1.orig
Only in binutils-2.37/ld: ld.1.rej
diff -rup binutils.orig/ld/ld.info binutils-2.37/ld/ld.info
--- binutils.orig/ld/ld.info 2022-06-08 15:54:20.068975306 +0200
+++ binutils-2.37/ld/ld.info 2022-06-08 15:57:57.845793445 +0200
@@ -2211,7 +2211,7 @@ GNU linker:
'--enable-new-dtags', the new dynamic tags will be created as
needed and older dynamic tags will be omitted. If you specify
'--disable-new-dtags', no new dynamic tags will be created. By
- default, the new dynamic tags are not created. Note that those
+ default, the new dynamic tags are created. Note that those
options are only available for ELF systems.
'--hash-size=NUMBER'
Only in binutils-2.37/ld: ld.info.orig
diff -rup binutils.orig/ld/ld.texi binutils-2.37/ld/ld.texi
--- binutils.orig/ld/ld.texi 2022-06-08 15:54:20.068975306 +0200
+++ binutils-2.37/ld/ld.texi 2022-06-08 15:57:57.850793464 +0200
@@ -2773,7 +2773,7 @@ systems may not understand them. If you
@option{--enable-new-dtags}, the new dynamic tags will be created as needed
and older dynamic tags will be omitted.
If you specify @option{--disable-new-dtags}, no new dynamic tags will be
-created. By default, the new dynamic tags are not created. Note that
+created. By default, the new dynamic tags are created. Note that
those options are only available for ELF systems.
@kindex --hash-size=@var{number}
Only in binutils-2.37/ld: ld.texi.orig

View file

@ -39,7 +39,7 @@
Summary: A GNU collection of binary utilities
Name: binutils%{?name_cross}%{?_with_debug:-debug}
Version: 2.37
Release: 25%{?dist}
Release: 38%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -337,6 +337,57 @@ Patch30: binutils-CVE-2021-45078.patch
# Lifetime: Who knows.
Patch31: gcc12-libtool-no-rpath.patch
# Purpose: Fix a potential illegal memory access parsing a corrupt ELF file.
# Lifetime: Fixed in 2.38.
Patch32: binutils-readelf-corrupt-program-headers.patch
# Purpose: Add an option to disable access to debuginfod servers.
# Lifetime: Fixed in 2.39
Patch33: binutils-do-not-use-debuginfod.patch
# Purpose: Support generating static PIE binaries for the s390x.
# Lifetime: Fixed in 2.39
Patch34: binutils-s390x-static-PIE.patch
# Purpose: Stop readelf and objdump from unnecessarily following links.
# Lifetime: Fixed in 2.39
Patch35: binutils-link-following.patch
%if %{enable_new_dtags}
# Purpose: Change ld man page so that it says that --enable-new-dtags is the default.
# Lifetime: Permanent
Patch36: binutils-update-linker-manual.patch
%endif
# Purpose: Add a --package-metadata option to the linkers.
# Lifetime: Fixed in 2.39 (for ld.bfd)
Patch37: binutils-package-metadata.patch
# Purpose: Fixes warning when running strip on an object file
# Lifetime: Fixed in 2.38
Patch38: binutils-strip-objcopy-preserve-dates.patch
# Purpose: Fixing bug 2120752
# Lifetime: Fixed in 2.39
Patch39: binutils-add-splay-tree-for-info_ptr.patch
# Purpose: Fixing bug 2120752
# Lifetime: Fixed in 2.39
Patch40: binutils-reduce-O-n2-performance-overhead-when-parsing-DWARF.patch
# Purpose: Stop an infinite loop in the binutils DWARF decoder. (CVE 2022-38128)
# Lifetime: Fixed in 2.40
Patch41: binutils-CVE-38128-dwarf-abbrev-parsing.patch
# Purpose: Stop readelf from incorrectly decoding ELF files with no sections.
# Lifetime: Fixed in 2.40
Patch42: binutils-readelf-no-sections.patch
# Purpose: Stop the linker from associating allocated reloc sections with
# the .symtab section , which prevents it from being stripped.
# Lifetime: Fixed in 2.41
Patch43: binutils-reloc-symtab.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -406,6 +457,9 @@ Requires(post): coreutils
BuildRequires: elfutils-debuginfod-client-devel
%endif
# The priority of the linker. Important oif the gold linker is also being built.
%{!?ld_bfd_priority: %global ld_bfd_priority 50}
#----------------------------------------------------------------------------
%description
@ -431,6 +485,14 @@ Requires: binutils = %{version}-%{release}
# BZ 1215242: We need touch...
Requires: coreutils
# BZ 1924068. Since applications that use the BFD library are
# required to link against the static version, ensure that it retains
# its debug informnation.
# FIXME: Yes - this is being done twice. I have no idea why this
# second invocation is necessary but if both are not present the
# static archives will be stripped.
%undefine __brp_strip_static_archive
%description devel
This package contains BFD and opcodes static and dynamic libraries.
@ -445,14 +507,6 @@ dynamic libraries.
Developers starting new projects are strongly encouraged to consider
using libelf instead of BFD.
# BZ 1924068. Since applications that use the BFD library are
# required to link against the static version, ensure that it retains
# its debug informnation.
# FIXME: Yes - this is being done twice. I have no idea why this
# second invocation is necessary but if both are not present the
# static archives will be stripped.
%undefine __brp_strip_static_archive
#----------------------------------------------------------------------------
%if %{with gold}
@ -462,13 +516,6 @@ Summary: The GOLD linker, a faster alternative to the BFD linker
Provides: gold = %{version}-%{release}
Requires: binutils >= %{version}
%description gold
This package provides the GOLD linker, which can be used as an alternative to
the default binutils linker (ld.bfd). The GOLD is generally faster than the
BFD linker, and it supports features such as Identical Code Folding and
Incremental linking. Unfortunately it is not as well maintained as the BFD
linker, and it may become deprecated in the future.
# Gold needs bison in order to build gold/yyscript.c.
BuildRequires: bison, m4, gcc-c++
# The GOLD testsuite needs a static libc++
@ -479,12 +526,17 @@ BuildRequires: gcc-c++
Conflicts: gcc-c++ < 4.0.0
%endif
# The higher of these two numbers determines the default ld.
# If ld_gold_priority is higher than ld_bfd_priority then it will be the default linker.
%{!?ld_gold_priority:%global ld_gold_priority 30}
%endif
%description gold
This package provides the GOLD linker, which can be used as an alternative to
the default binutils linker (ld.bfd). The GOLD is generally faster than the
BFD linker, and it supports features such as Identical Code Folding and
Incremental linking. Unfortunately it is not as well maintained as the BFD
linker, and it may become deprecated in the future.
%{!?ld_bfd_priority: %global ld_bfd_priority 50}
%endif
#----------------------------------------------------------------------------
@ -578,7 +630,7 @@ CARGS=
CARGS="$CARGS --with-debuginfod"
%endif
%ifarch %{ix86} x86_64 ppc %{power64} s390 s390x sh3 sh4 sparc sparc64 arm
%ifarch %{ix86} x86_64 ppc %{power64} s390 s390x sh3 sh4 sparc sparc64 arm aarch64 riscv64
CARGS="$CARGS --enable-64-bit-bfd"
%endif
@ -591,11 +643,11 @@ CARGS="$CARGS --enable-64-bit-bfd"
# Also enable the BPF target so that strip will work on BPF files.
case %{binutils_target} in
s390*)
# FIXME: For some unknown reason settting --enable-targets=x86_64-pep
# here breaks the building of GOLD. I have no idea why, and not enough
# knowledge of how gold is configured to fix quickly. So instead I have
# found that supporting "all" targets works.
CARGS="$CARGS --enable-targets=all"
# Note - The s390-linux target is there so that the GOLD linker will
# build. By default, if configured for just s390x-linux, the GOLD
# configure system will only include support for 64-bit targets, but
# the s390x gold backend uses both 32-bit and 64-bit templates.
CARGS="$CARGS --enable-targets=s390-linux,s390x-linux,x86_64-pep,bpf-unknown-none"
;;
ia64*)
CARGS="$CARGS --enable-targets=ia64-linux,x86_64-pep,bpf-unknown-none"
@ -777,7 +829,7 @@ rm -f %{buildroot}%{_libdir}/lib{bfd,opcodes}.so
rm -f %{buildroot}%{_libdir}/*.la
# Fix multilib conflicts of generated values by __WORDSIZE-based expressions.
%ifarch %{ix86} x86_64 ppc %{power64} s390 s390x sh3 sh4 sparc sparc64 arm
%ifarch %{ix86} x86_64 ppc %{power64} s390 s390x sh3 sh4 sparc sparc64 arm aarch64 riscv64
# Sanity check --enable-64-bit-bfd really works.
grep '^#define BFD_ARCH_SIZE 64$' %{buildroot}%{_prefix}/include/bfd.h
sed -i -e '/^#include "ansidecl.h"/{p;s~^.*$~#include <bits/wordsize.h>~;}' \
@ -906,6 +958,9 @@ exit 0
# %%verify(symlink) does not work for some reason, so using "owner" instead.
%verify(owner) %{_bindir}/%{?cross}ld
%{_bindir}/%{?cross}ld.bfd
# Do not export any Windows tools (if they were built)
%exclude %{_bindir}/%{?cross}dll*
%exclude %{_bindir}/%{?cross}wind*
%if %{with docs}
%{_mandir}/man1/
@ -946,6 +1001,52 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Thu Mar 30 2023 Nick Clifton <nickc@redhat.com> - 2.37-38
- Linker: Do not associate allocated reloc sections with the .symtab section. (#2166419)
* Wed Nov 16 2022 Yara Ahmad <yahmad@redhat.com> - 2.37-37
- Fic configuration of s390x binutils so that it does not include support for extraneous targets. (#2139143)
- Fix readelf's decoding of files with no sections. (#2131609)
- Stop potential infinite loop in the binutils DWARF parser. (#2122675)
NOTE: Getting back in sync. Previous commit was done by mistake.
(commit f3e2e5419db81abb950d61ee197d1afcc910a0cc)
* Wed Sep 07 2022 Yara Ahmad <yahmad@redhat.com> - 2.37-36
- Improving the performance of bfd function lookup_func_by_offset
* Wed Aug 10 2022 Yara Ahmad <yahmad@redhat.com> - 2.37-35
- Fixes warning when running strip on an object file (#2114597)
* Fri Aug 05 2022 Yara Ahmad <yahmad@redhat.com> - 2.37-34
- Add the --package-metadata option to the linkers. (#2099999)
* Wed Aug 03 2022 Yara Ahmad <yahmad@redhat.com> - 2.37-33
- Restore the use of --enable-64-bit-bfd for the AArch64 and riscv64 targets.
- Check and enable 64-bit bfd on aarch64 and riscv64.
* Thu Jun 30 2022 Nick Clifton <nickc@redhat.com> - 2.37-32
- Fix a problem honouring readelf's -wE and -wN command line options.
* Wed Jun 8 2022 Yara Ahmad <yahmad@redhat.com> - 2.37-31
- Fix bug in binutils.spec file that was causing the wrong linker flags to be used.
- Change the ld man page so that it says that --enable-new-dtags is the default. (#2090818)
* Sat May 21 2022 Nick Clifton <nickc@redhat.comn> - 2.37-30
- Stop readelf and objdump from unnecessarily following links. (#2086863)
* Thu May 19 2022 Nick Clifton <nickc@redhat.comn> - 2.37-29
- Add support for generating static PIE binaries for s390x. (#2088331)
* Thu May 19 2022 Yara Ahmad <yahmad@redhat.com> - 2.37-28
- Fix description of gold subpackage so that it does not include the Requires fields. (#2082919)
* Thu Mar 10 2022 Nick Clifton <nickc@redhat.comn> - 2.37-27
- Add an option to objdump/readelf to disable accessing debuginfod servers. (#2051741)
* Thu Feb 10 2022 Nick Clifton <nickc@redhat.comn> - 2.37-26
- Fix a potential illegal memory access parsing a corrupt ELF format file. (#2052522)
* Thu Jan 27 2022 Nick Clifton <nickc@redhat.comn> - 2.37-25
- Borrow a patch from the GCC package to stop libtool from inserting needless runpaths into binaries. (#2030667)

View file

@ -1,6 +1,5 @@
summary: CI Gating Plan
discover:
how: fmf
directory: tests
execute:
how: beakerlib
how: tmt