Commit: PR 27478: readelf/objcopy: Add new option to enable displaying contents of linked files

Nick Clifton nickc@redhat.com
Thu Mar 4 10:41:08 GMT 2021


Hi Guys,

  I am applying the patch below to address PR 27478 and also the
  problems raised by enabling the automatic following of links to
  separate debuginfo files.  The patch adds a new option
  '--process-links' which tells the tool to display the contents of
  non-debug sections in the linked file(s).  If the option is not used
  then the string and symbol tables will still be loaded from the linked
  files but their contents will not be displayed.  (Note - this does not
  apply to debug sections.  If one or more of these sections are being
  dumped then they will be displayed in both the main file and linked
  file(s).  This is because in most cases the debug sections will only
  be present in either the main file or the separate files).

  Whilst testing the patch I came across a strange phenomenon. Sometimes
  the comparison tests in binutils-all/compress.exp would fail.  When I
  investigated it appeared that the cause was that the original file
  contained section symbols, whilst the stripped file did not.  So I
  added a new option to strip '--keep-section-symbols' to solve this.
  But then the tests started failing again because the original file no
  longer contained section symbols.  I think that somehow the test
  harness was using different versions of the linker in different runs
  of the test.  But I was never able to verify this.  I felt however
  that there might be some utility to having an option to retain section
  symbols, so I have left the option in the patch.

Cheers
  Nick

binutils/ChangeLog
2021-03-04  Nick Clifton  <nickc@redhat.com>

	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.
        
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr27478.patch
Type: text/x-patch
Size: 44636 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20210304/44335c6d/attachment-0001.bin>


More information about the Binutils mailing list