Gate the displaying of non-debug sections in separate debuginfo files.

PR 27478
	* objdump.c (process_links): New variable.
	(usage): Add --process-links.
	(long_options): Likewise.
	(dump_bfd): Stop processing once the bfd has been loaded unless
	this is the main file or process_links has been enabled.
	(main): Handle the process-links option.
	* readelf.c (process_links): New variable.
	(struct filedata): Add is_separate field.
	(options): Add --process-links.
	(usage): Likewise.
	(parse_args): Likewise.
	(process_file_header): Include the filename when dumping
	information for separate debuginfo files.
	(process_program_headers): Likewise.
	(process_section_headers): Likewise.
	(process_section_groups): Likewise.
	(process_relocs): Likewise.
	(process_dynamic_section): Likewise.
	(process_version_sections): Likewise.
	(display_lto_symtab): Likewise.
	(process_symbol_table): Likewise.
	(process_syminfo): Likewise.
	(initialise_dumps_by_name): Likewise.
	(process_section_contents): Likewise.
	(process_notes_at): Likewise.
	(process_notes): Likewise.
	(open_file): Add is_separate parameter.  Use to initialise the
	is_separate field in the filedata structure.
	(open_deug): Update call to open_file.
	(process_object): Add processing of the contents of separate
	debuginfo files, gated by the process_links variable.
	(process_archive): Update call to open_file.
	(process_file): Initialise the is_separate field in the filedata
	structure.
	* dwarf.c (load_separate_debug_info_file): Only report the
	loading of a separate file if debug links are being dumped.
	* objcopy.c (keep_section_symbols): New variable.
	(enum command_line_switch): Add OPTION_KEEP_SYMBOLS.
	(strip_options): Add keep-section-symbols.
	(copy_options): Likewise.
	(copy_usage): Likewise.
	(strip_usage): Likewise.
	(copy_object): Keep section symbols if requested by command line
	option.
	(strip_main): Handle --keep-section-symbols.
	(copy_main): Likewise.
	* doc/binutils.texi: Document the new options.
	* NEWS: Mention the new features.
	* testsuite/binutils-all/compress.exp (test_gnu_debuglink):
	Update options passed to objdump.  Use diff rather than cmp to
	compare the dumped data.
	* testsuite/binutils-all/objdump.WK2: Update regexp.
	* testsuite/binutils-all/objdump.WK3: Update regexp.
	* testsuite/binutils-all/objdump.exp: Use --process-links
	instead of --dwarf=follow-links.
	* testsuite/binutils-all/readelf.exp (readelf_test): Include
	readelf's output in the log when the test fails.
	Add the -P option to the -wKis test.
	* testsuite/binutils-all/readelf.wKis: Update expected output.
This commit is contained in:
Nick Clifton
2021-03-04 10:41:22 +00:00
parent 168bb18858
commit ca0e11aa4b
13 changed files with 461 additions and 108 deletions

View File

@@ -1210,6 +1210,8 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
[@option{-g}|@option{--strip-debug}]
[@option{--strip-unneeded}]
[@option{-K} @var{symbolname}|@option{--keep-symbol=}@var{symbolname}]
[@option{--keep-file-symbols}]
[@option{--keep-section-symbols}]
[@option{-N} @var{symbolname}|@option{--strip-symbol=}@var{symbolname}]
[@option{--strip-unneeded-symbol=}@var{symbolname}]
[@option{-G} @var{symbolname}|@option{--keep-global-symbol=}@var{symbolname}]
@@ -1266,7 +1268,6 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
[@option{--prefix-sections=}@var{string}]
[@option{--prefix-alloc-sections=}@var{string}]
[@option{--add-gnu-debuglink=}@var{path-to-file}]
[@option{--keep-file-symbols}]
[@option{--only-keep-debug}]
[@option{--strip-dwo}]
[@option{--extract-dwo}]
@@ -1967,6 +1968,11 @@ As long as the debug info file has been installed into one of these
locations before the debugger is run everything should work
correctly.
@item --keep-section-symbils
When stripping a file, perhaps with @option{--strip-debug} or
@option{--strip-unneeded}, retain any symbols specifying section names,
which would otherwise get stripped.
@item --keep-file-symbols
When stripping a file, perhaps with @option{--strip-debug} or
@option{--strip-unneeded}, retain any symbols specifying source file names,
@@ -2202,6 +2208,7 @@ objdump [@option{-a}|@option{--archive-headers}]
@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{-L}|@option{--process-links}]
[@option{--ctf=}@var{section}]
[@option{-G}|@option{--stabs}]
[@option{-t}|@option{--syms}]
@@ -2441,6 +2448,13 @@ for specification with @option{-b} or @option{-m}.
@cindex section information
Display information only for section @var{name}.
@item -L
@itemx --process-links
Display the contents of non-debug sections found in separate debuginfo
files that are linked to the main file. This option automatically
implies the @option{-WK} option, and only sections requested by other
command line options will be displayed.
@item -l
@itemx --line-numbers
@cindex source filenames for object files
@@ -3321,6 +3335,7 @@ strip [@option{-F} @var{bfdname} |@option{--target=}@var{bfdname}]
[@option{-o} @var{file}] [@option{-p}|@option{--preserve-dates}]
[@option{-D}|@option{--enable-deterministic-archives}]
[@option{-U}|@option{--disable-deterministic-archives}]
[@option{--keep-section-symbols}]
[@option{--keep-file-symbols}]
[@option{--only-keep-debug}]
[@option{-v} |@option{--verbose}] [@option{-V}|@option{--version}]
@@ -3516,6 +3531,11 @@ Remove non-global symbols.
Remove compiler-generated local symbols.
(These usually start with @samp{L} or @samp{.}.)
@item --keep-section-symbols
When stripping a file, perhaps with @option{--strip-debug} or
@option{--strip-unneeded}, retain any symbols specifying section names,
which would otherwise get stripped.
@item --keep-file-symbols
When stripping a file, perhaps with @option{--strip-debug} or
@option{--strip-unneeded}, retain any symbols specifying source file names,
@@ -4771,6 +4791,7 @@ 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{-P}|@option{--process-links}]
[@option{--dwarf-depth=@var{n}}]
[@option{--dwarf-start=@var{n}}]
[@option{--ctf=}@var{section}]
@@ -5003,6 +5024,13 @@ command to @command{ar}, but without using the BFD library. @xref{ar}.
@itemx --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,=follow-links]
@include debug.options.texi
@item -P
@itemx --process-links
Display the contents of non-debug sections found in separate debuginfo
files that are linked to the main file. This option automatically
implies the @option{-wK} option, and only sections requested by other
command line options will be displayed.
@include ctf.options.texi
@item --ctf-symbols=@var{section}
@item --ctf-strings=@var{section}