mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 09:58:19 +08:00
Stop readekf and objdump from aggressively following links.
* dwarf.c (dwarf_select_sections_by_names): Return zero if no sections were selected. (dwarf_select_sections_by_letters): Likewise. * dwarf.h: (dwarf_select_sections_by_names): Update prototype. (dwarf_select_sections_by_letters): Update prototype. * objdump.c (might_need_separate_debug_info): New function. (dump_bfd): Call new function before attempting to load separate debug info files. (main): Do not enable dwarf section dumping for -WK or -WN. * readelf.c (parse_args): Do not enable dwarf section dumping for -wK or -wN. (might_need_separate_debug_info): New function. (process_object): Call new function before attempting to load separate debug info files. * testsuite/binutils-all/debuginfo.exp: Expect -WE and -wE debuginfod tests to pass. * testsuite/binutils-all/objdump.Wk: Add extra regexps. * testsuite/binutils-all/readelf.k: Add extra regexps.
This commit is contained in:
@ -1,3 +1,24 @@
|
|||||||
|
2022-05-20 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
* dwarf.c (dwarf_select_sections_by_names): Return zero if no
|
||||||
|
sections were selected.
|
||||||
|
(dwarf_select_sections_by_letters): Likewise.
|
||||||
|
* dwarf.h: (dwarf_select_sections_by_names): Update prototype.
|
||||||
|
(dwarf_select_sections_by_letters): Update prototype.
|
||||||
|
* objdump.c (might_need_separate_debug_info): New function.
|
||||||
|
(dump_bfd): Call new function before attempting to load separate
|
||||||
|
debug info files.
|
||||||
|
(main): Do not enable dwarf section dumping for -WK or -WN.
|
||||||
|
* readelf.c (parse_args): Do not enable dwarf section dumping for
|
||||||
|
-wK or -wN.
|
||||||
|
(might_need_separate_debug_info): New function.
|
||||||
|
(process_object): Call new function before attempting to load
|
||||||
|
separate debug info files.
|
||||||
|
* testsuite/binutils-all/debuginfo.exp: Expect -WE and -wE
|
||||||
|
debuginfod tests to pass.
|
||||||
|
* testsuite/binutils-all/objdump.Wk: Add extra regexps.
|
||||||
|
* testsuite/binutils-all/readelf.k: Add extra regexps.
|
||||||
|
|
||||||
2022-05-19 Nick Clifton <nickc@redhat.com>
|
2022-05-19 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
* dlltool.c (run): Initialise errmsg_fmt.
|
* dlltool.c (run): Initialise errmsg_fmt.
|
||||||
|
110
binutils/dwarf.c
110
binutils/dwarf.c
@ -12062,7 +12062,11 @@ free_debug_memory (void)
|
|||||||
free_dwo_info ();
|
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)
|
dwarf_select_sections_by_names (const char *names)
|
||||||
{
|
{
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -12115,6 +12119,7 @@ dwarf_select_sections_by_names (const char *names)
|
|||||||
};
|
};
|
||||||
|
|
||||||
const char *p;
|
const char *p;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
p = names;
|
p = names;
|
||||||
while (*p)
|
while (*p)
|
||||||
@ -12129,6 +12134,7 @@ dwarf_select_sections_by_names (const char *names)
|
|||||||
&& (p[len] == ',' || p[len] == '\0'))
|
&& (p[len] == ',' || p[len] == '\0'))
|
||||||
{
|
{
|
||||||
* entry->variable = entry->val;
|
* entry->variable = entry->val;
|
||||||
|
result |= entry->val;
|
||||||
|
|
||||||
/* The --debug-dump=frames-interp option also
|
/* The --debug-dump=frames-interp option also
|
||||||
enables the --debug-dump=frames option. */
|
enables the --debug-dump=frames option. */
|
||||||
@ -12151,48 +12157,82 @@ dwarf_select_sections_by_names (const char *names)
|
|||||||
if (*p == ',')
|
if (*p == ',')
|
||||||
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)
|
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])
|
static const debug_dump_letter_opts letter_table [] =
|
||||||
switch (letters[lindex++])
|
{
|
||||||
{
|
{ 'A', & do_debug_addr, 1, false},
|
||||||
case 'A': do_debug_addr = 1; break;
|
{ 'a', & do_debug_abbrevs, 1, false },
|
||||||
case 'a': do_debug_abbrevs = 1; break;
|
{ 'c', & do_debug_cu_index, 1, false },
|
||||||
case 'c': do_debug_cu_index = 1; break;
|
|
||||||
#ifdef HAVE_LIBDEBUGINFOD
|
#ifdef HAVE_LIBDEBUGINFOD
|
||||||
case 'D': use_debuginfod = 1; break;
|
{ 'D', & use_debuginfod, 1, false },
|
||||||
case 'E': use_debuginfod = 0; break;
|
{ 'E', & use_debuginfod, 0, false },
|
||||||
#endif
|
#endif
|
||||||
case 'F': do_debug_frames_interp = 1; /* Fall through. */
|
{ 'F', & do_debug_frames_interp, 1, true }, /* Note the fall through. */
|
||||||
case 'f': do_debug_frames = 1; break;
|
{ 'f', & do_debug_frames, 1, false },
|
||||||
case 'g': do_gdb_index = 1; break;
|
{ 'g', & do_gdb_index, 1, false },
|
||||||
case 'i': do_debug_info = 1; break;
|
{ 'i', & do_debug_info, 1, false },
|
||||||
case 'K': do_follow_links = 1; break;
|
{ 'K', & do_follow_links, 1, false },
|
||||||
case 'N': do_follow_links = 0; break;
|
{ 'k', & do_debug_links, 1, false },
|
||||||
case 'k': do_debug_links = 1; break;
|
{ 'L', & do_debug_lines, FLAG_DEBUG_LINES_DECODED, false },
|
||||||
case 'l': do_debug_lines |= FLAG_DEBUG_LINES_RAW; break;
|
{ 'l', & do_debug_lines, FLAG_DEBUG_LINES_RAW, false },
|
||||||
case 'L': do_debug_lines |= FLAG_DEBUG_LINES_DECODED; break;
|
{ 'm', & do_debug_macinfo, 1, false },
|
||||||
case 'm': do_debug_macinfo = 1; break;
|
{ 'N', & do_follow_links, 0, false },
|
||||||
case 'O': do_debug_str_offsets = 1; break;
|
{ 'O', & do_debug_str_offsets, 1, false },
|
||||||
case 'o': do_debug_loc = 1; break;
|
{ 'o', & do_debug_loc, 1, false },
|
||||||
case 'p': do_debug_pubnames = 1; break;
|
{ 'p', & do_debug_pubnames, 1, false },
|
||||||
case 'R': do_debug_ranges = 1; break;
|
{ 'R', & do_debug_ranges, 1, false },
|
||||||
case 'r': do_debug_aranges = 1; break;
|
{ 'r', & do_debug_aranges, 1, false },
|
||||||
case 's': do_debug_str = 1; break;
|
{ 's', & do_debug_str, 1, false },
|
||||||
case 'T': do_trace_aranges = 1; break;
|
{ 'T', & do_trace_aranges, 1, false },
|
||||||
case 't': do_debug_pubtypes = 1; break;
|
{ 't', & do_debug_pubtypes, 1, false },
|
||||||
case 'U': do_trace_info = 1; break;
|
{ 'U', & do_trace_info, 1, false },
|
||||||
case 'u': do_trace_abbrevs = 1; break;
|
{ 'u', & do_trace_abbrevs, 1, false },
|
||||||
|
{ 0, NULL, 0, false }
|
||||||
|
};
|
||||||
|
|
||||||
default:
|
int result = 0;
|
||||||
warn (_("Unrecognized debug option '%s'\n"), letters);
|
|
||||||
break;
|
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
|
void
|
||||||
|
@ -250,8 +250,8 @@ extern void *open_debug_file (const char *);
|
|||||||
|
|
||||||
extern void free_debug_memory (void);
|
extern void free_debug_memory (void);
|
||||||
|
|
||||||
extern void dwarf_select_sections_by_names (const char *);
|
extern int dwarf_select_sections_by_names (const char *);
|
||||||
extern void dwarf_select_sections_by_letters (const char *);
|
extern int dwarf_select_sections_by_letters (const char *);
|
||||||
extern void dwarf_select_sections_all (void);
|
extern void dwarf_select_sections_all (void);
|
||||||
|
|
||||||
extern unsigned int * find_cu_tu_set (void *, unsigned int);
|
extern unsigned int * find_cu_tu_set (void *, unsigned int);
|
||||||
|
@ -5188,6 +5188,26 @@ sign_extend_address (bfd *abfd ATTRIBUTE_UNUSED,
|
|||||||
return (((vma & ((mask << 1) - 1)) ^ mask) - mask);
|
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. */
|
/* Dump selected contents of ABFD. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -5202,16 +5222,8 @@ dump_bfd (bfd *abfd, bool is_mainfile)
|
|||||||
else
|
else
|
||||||
byte_get = NULL;
|
byte_get = NULL;
|
||||||
|
|
||||||
/* Load any separate debug information files.
|
/* Load any separate debug information files. */
|
||||||
We do this now and without checking do_follow_links because separate
|
if (byte_get != NULL && might_need_separate_debug_info (is_mainfile))
|
||||||
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_separate_debug_files (abfd, bfd_get_filename (abfd));
|
load_separate_debug_files (abfd, bfd_get_filename (abfd));
|
||||||
|
|
||||||
@ -5783,20 +5795,30 @@ main (int argc, char **argv)
|
|||||||
do_follow_links = true;
|
do_follow_links = true;
|
||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
dump_dwarf_section_info = true;
|
|
||||||
seenflag = true;
|
seenflag = true;
|
||||||
if (optarg)
|
if (optarg)
|
||||||
dwarf_select_sections_by_letters (optarg);
|
{
|
||||||
|
if (dwarf_select_sections_by_letters (optarg))
|
||||||
|
dump_dwarf_section_info = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
dwarf_select_sections_all ();
|
{
|
||||||
|
dump_dwarf_section_info = true;
|
||||||
|
dwarf_select_sections_all ();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case OPTION_DWARF:
|
case OPTION_DWARF:
|
||||||
dump_dwarf_section_info = true;
|
|
||||||
seenflag = true;
|
seenflag = true;
|
||||||
if (optarg)
|
if (optarg)
|
||||||
dwarf_select_sections_by_names (optarg);
|
{
|
||||||
|
if (dwarf_select_sections_by_names (optarg))
|
||||||
|
dump_dwarf_section_info = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
dwarf_select_sections_all ();
|
{
|
||||||
|
dwarf_select_sections_all ();
|
||||||
|
dump_dwarf_section_info = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case OPTION_DWARF_DEPTH:
|
case OPTION_DWARF_DEPTH:
|
||||||
{
|
{
|
||||||
|
@ -5526,31 +5526,39 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
|
|||||||
decompress_dumps = true;
|
decompress_dumps = true;
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
do_dump = true;
|
|
||||||
dump_any_debugging = true;
|
|
||||||
if (optarg == NULL)
|
if (optarg == NULL)
|
||||||
{
|
{
|
||||||
do_debugging = true;
|
do_debugging = true;
|
||||||
|
do_dump = true;
|
||||||
|
dump_any_debugging = true;
|
||||||
dwarf_select_sections_all ();
|
dwarf_select_sections_all ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
do_debugging = false;
|
do_debugging = false;
|
||||||
dwarf_select_sections_by_letters (optarg);
|
if (dwarf_select_sections_by_letters (optarg))
|
||||||
|
{
|
||||||
|
do_dump = true;
|
||||||
|
dump_any_debugging = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPTION_DEBUG_DUMP:
|
case OPTION_DEBUG_DUMP:
|
||||||
do_dump = true;
|
|
||||||
dump_any_debugging = true;
|
|
||||||
if (optarg == NULL)
|
if (optarg == NULL)
|
||||||
{
|
{
|
||||||
|
do_dump = true;
|
||||||
do_debugging = true;
|
do_debugging = true;
|
||||||
|
dump_any_debugging = true;
|
||||||
dwarf_select_sections_all ();
|
dwarf_select_sections_all ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
do_debugging = false;
|
do_debugging = false;
|
||||||
dwarf_select_sections_by_names (optarg);
|
if (dwarf_select_sections_by_names (optarg))
|
||||||
|
{
|
||||||
|
do_dump = true;
|
||||||
|
dump_any_debugging = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPTION_DWARF_DEPTH:
|
case OPTION_DWARF_DEPTH:
|
||||||
@ -22252,6 +22260,26 @@ initialise_dump_sects (Filedata * filedata)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|| dump_any_debugging || do_dump || do_debugging)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Process one ELF object file according to the command line options.
|
/* Process one ELF object file according to the command line options.
|
||||||
This file may actually be stored in an archive. The file is
|
This file may actually be stored in an archive. The file is
|
||||||
positioned at the start of the ELF object. Returns TRUE if no
|
positioned at the start of the ELF object. Returns TRUE if no
|
||||||
@ -22335,7 +22363,7 @@ process_object (Filedata * filedata)
|
|||||||
if (! process_version_sections (filedata))
|
if (! process_version_sections (filedata))
|
||||||
res = false;
|
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);
|
have_separate_files = load_separate_debug_files (filedata, filedata->file_name);
|
||||||
else
|
else
|
||||||
have_separate_files = false;
|
have_separate_files = false;
|
||||||
|
@ -189,7 +189,7 @@ if { [regexp ".*DEBUGINFOD.*" $conf_objdump] } {
|
|||||||
test_fetch_debugaltlink $OBJDUMP "-Wk"
|
test_fetch_debugaltlink $OBJDUMP "-Wk"
|
||||||
|
|
||||||
set test "disabling debuginfod access"
|
set test "disabling debuginfod access"
|
||||||
setup_xfail *-*-*
|
# setup_xfail *-*-*
|
||||||
test_fetch_debuglink $OBJDUMP "-W -WE"
|
test_fetch_debuglink $OBJDUMP "-W -WE"
|
||||||
set test "debuginfod"
|
set test "debuginfod"
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ if { [regexp ".*DEBUGINFOD.*" $conf_readelf] } {
|
|||||||
test_fetch_debugaltlink $READELF "-wk"
|
test_fetch_debugaltlink $READELF "-wk"
|
||||||
|
|
||||||
set test "disabling debuginfod access"
|
set test "disabling debuginfod access"
|
||||||
setup_xfail *-*-*
|
# setup_xfail *-*-*
|
||||||
test_fetch_debuglink $READELF "-w -wE"
|
test_fetch_debuglink $READELF "-w -wE"
|
||||||
set test "debuginfod"
|
set test "debuginfod"
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
#...
|
||||||
tmpdir/debuglink\.o: file format .*
|
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
|
Separate debug info file: this_is_a_debuglink\.debug
|
||||||
CRC value: 0x12345678
|
CRC value: 0x12345678
|
||||||
Contents of the \.gnu_debugaltlink section:
|
Contents of the \.gnu_debugaltlink section.*
|
||||||
Separate debug info file: linkdebug\.debug
|
Separate debug info file: linkdebug\.debug
|
||||||
Build-ID \(0x18 bytes\):
|
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
|
00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 01 23 45 67 89 ab cd ef
|
||||||
|
@ -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
|
Separate debug info file: this_is_a_debuglink\.debug
|
||||||
CRC value: 0x12345678
|
CRC value: 0x12345678
|
||||||
Contents of the \.gnu_debugaltlink section:
|
Contents of the \.gnu_debugaltlink section.*
|
||||||
Separate debug info file: linkdebug\.debug
|
Separate debug info file: linkdebug\.debug
|
||||||
Build-ID \(0x18 bytes\):
|
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
|
00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 01 23 45 67 89 ab cd ef
|
||||||
|
Reference in New Issue
Block a user