RFC: Objcopy --only-keep-debug update

Nick Clifton nickc@redhat.com
Wed Jul 29 13:35:00 GMT 2015


Hi Guys,

  Right - now that I understand why --only-keep-debug is leaving in the
  section headers of stripped sections, I have a two part patch for you
  to consider.

  The first part updates the binutils documentation, explaining why the
  headers are preserved.  Hopefully this will stop other people from
  falling into the same trap that I fell into, thinking that strip was
  failing to actually delete non-debug sections.

  The second part of the patch fixes a problem with the sh_link fields
  in the stripped section headers - it was always being set to zero.
  Although technically this is valid, it is a problem for other tools
  which try to match up the section headers in the debug-only file with
  the section headers in the stripped-of-debug-info file.  Leaving the
  links intact helps these tools match up the two files.

  One problem I did have with this part of the patch was in determining
  which sections should have their sh_link fields preserved.  In the end
  I had to encode the section names directly, but I feel that their
  ought to be a better way.
  
  The second part of the patch also adds a testcase to the binutils
  testsuite to check that the sh_link values are preserved.

  Tested with no regressions on lots of different toolchains.
  
  What do people think - any objections or problems with the patch ?

Cheers
  Nick

bfd/ChangeLog
2015-07-29  Nick Clifton  <nickc@redhat.com>

	* elf.c (sec_links_to_symtab): New function.
        (sec_links_to_strtab): New function.
        (assign_section_numbers): Set the sh_link field in NOBITS
        sections that would have that field set if their type was not
        NOBITS.

binutils/ChangeLog

	* doc/binutils.texi (objcopy): Note the --only-keep-debug
	retains the headers of stripped sections.
        (strip): Likewise.

binutils/testsuite/ChangeLog

	* binutils-all/objcopy.exp (keep_debug_symbols_and_check_links):
	New proc/test.  Checks the sh_link fields of NOBITS sections in
	a --only-keep-debug stripped executable.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: objcopy.only-keep-debug.patch.2
Type: application/x-troff-man
Size: 8217 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20150729/73616728/attachment.2>


More information about the Binutils mailing list