aboutsummaryrefslogtreecommitdiff
path: root/binutils/readelf.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2022-05-20 16:55:36 +0100
committerNick Clifton <nickc@redhat.com>2022-05-20 16:55:36 +0100
commit94585d6d4495a001dd5023f728150c96d5740ba8 (patch)
treee2ae934b5864bda0281b1dbf39e153018256451c /binutils/readelf.c
parent9ecdcd1be1e8487fca035c588d17a102d1f8b5eb (diff)
downloadbinutils-94585d6d4495a001dd5023f728150c96d5740ba8.zip
binutils-94585d6d4495a001dd5023f728150c96d5740ba8.tar.gz
binutils-94585d6d4495a001dd5023f728150c96d5740ba8.tar.bz2
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.
Diffstat (limited to 'binutils/readelf.c')
-rw-r--r--binutils/readelf.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/binutils/readelf.c b/binutils/readelf.c
index d45e092..c35bfc1 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -5526,31 +5526,39 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
decompress_dumps = true;
break;
case 'w':
- do_dump = true;
- dump_any_debugging = true;
if (optarg == NULL)
{
do_debugging = true;
+ do_dump = true;
+ dump_any_debugging = true;
dwarf_select_sections_all ();
}
else
{
do_debugging = false;
- dwarf_select_sections_by_letters (optarg);
+ if (dwarf_select_sections_by_letters (optarg))
+ {
+ do_dump = true;
+ dump_any_debugging = true;
+ }
}
break;
case OPTION_DEBUG_DUMP:
- do_dump = true;
- dump_any_debugging = true;
if (optarg == NULL)
{
+ do_dump = true;
do_debugging = true;
+ dump_any_debugging = true;
dwarf_select_sections_all ();
}
else
{
do_debugging = false;
- dwarf_select_sections_by_names (optarg);
+ if (dwarf_select_sections_by_names (optarg))
+ {
+ do_dump = true;
+ dump_any_debugging = true;
+ }
}
break;
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.
This file may actually be stored in an archive. The file is
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))
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;