Change the behaviour of the --only-keep-debug option to objcopy and strip so that the sh_link and sh_info fields in stripped section headers are preserved.

bfd	* elf.c (_bfd_elf_copy_private_bfd_data): Copy the sh_link and
	sh_info fields of sections whose type has been changed to
	SHT_NOBITS.

bin	* doc/binutils.texi: Document that the --only-keep-debug option
	to strip and objcopy preserves the section headers of stripped
	sections.

tests	* binutils-all/objcopy.exp (keep_debug_symbols_and_check_links):
	New proc.  Checks that debug-info-only binaries retain the
	sh_link field in stripped sections.
This commit is contained in:
Nick Clifton 2015-08-05 16:16:39 +01:00
parent 260439cb8e
commit 63b9bbb7d7
6 changed files with 157 additions and 2 deletions

View file

@ -1731,6 +1731,12 @@ Strip a file, removing contents of any sections that would not be
stripped by @option{--strip-debug} and leaving the debugging sections
intact. In ELF files, this preserves all note sections in the output.
Note - the section headers of the stripped sections are preserved,
including their sizes, but the contents of the section are discarded.
The section headers are preserved so that other tools can match up the
debuginfo file with the real executable, even if that executable has
been relocated to a different address space.
The intention is that this option will be used in conjunction with
@option{--add-gnu-debuglink} to create a two part executable. One a
stripped binary which will occupy less space in RAM and in a
@ -3074,9 +3080,16 @@ When stripping a file, perhaps with @option{--strip-debug} or
which would otherwise get stripped.
@item --only-keep-debug
Strip a file, removing contents of any sections that would not be
Strip a file, emptying the contents of any sections that would not be
stripped by @option{--strip-debug} and leaving the debugging sections
intact. In ELF files, this preserves all note sections in the output.
intact. In ELF files, this preserves all the note sections in the
output as well.
Note - the section headers of the stripped sections are preserved,
including their sizes, but the contents of the section are discarded.
The section headers are preserved so that other tools can match up the
debuginfo file with the real executable, even if that executable has
been relocated to a different address space.
The intention is that this option will be used in conjunction with
@option{--add-gnu-debuglink} to create a two part executable. One a