diff options
author | Nick Clifton <nickc@redhat.com> | 2022-05-20 16:55:36 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2022-05-20 16:55:36 +0100 |
commit | 94585d6d4495a001dd5023f728150c96d5740ba8 (patch) | |
tree | e2ae934b5864bda0281b1dbf39e153018256451c /binutils/objdump.c | |
parent | 9ecdcd1be1e8487fca035c588d17a102d1f8b5eb (diff) | |
download | gdb-94585d6d4495a001dd5023f728150c96d5740ba8.zip gdb-94585d6d4495a001dd5023f728150c96d5740ba8.tar.gz gdb-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/objdump.c')
-rw-r--r-- | binutils/objdump.c | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/binutils/objdump.c b/binutils/objdump.c index 060a136..f585c1b 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -5188,6 +5188,26 @@ sign_extend_address (bfd *abfd ATTRIBUTE_UNUSED, 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 @@ -5202,16 +5222,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 (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)); @@ -5783,20 +5795,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: { |