Check sh_type/sh_flags/sh_addralign/sh_entsize when copying sh_link/sh_info
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 7 Aug 2015 17:28:42 +0000 (10:28 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 7 Aug 2015 17:35:58 +0000 (10:35 -0700)
commitd4ac1f878ecef58f1e4b4ff0cbfb4b475656eaf4
tree95f22b0c72cd452bb7b2114d8e6d0a46f34ad42e
parentf12899e9f081bb857c96999386e64a4252c4a325
Check sh_type/sh_flags/sh_addralign/sh_entsize when copying sh_link/sh_info

When copying the sh_link and sh_info fields in stripped section headers,
we also check if the sh_type, sh_flags, /sh_addralign and sh_entsize
fields of the output section match the output.  Since --only-keep-debug
turns all non-debug sections into SHT_NOBITS sections, the output
SHT_NOBITS type matches any input type.

bfd/

PR binutils/18785
* elf.c (_bfd_elf_copy_private_bfd_data): When copying the
sh_link and sh_info fields in stripped section headers, we also
check if the sh_type, sh_flags, /sh_addralign and sh_entsize
fields of the output section match the output.  Since
--only-keep-debug turns all non-debug sections into SHT_NOBITS
sections, the output SHT_NOBITS type matches any input type.

binutils/testsuite/

PR binutils/18785
* binutils-all/objcopy.exp: Run strip-12.
* binutils-all/strip-12.d: New file.
* binutils-all/strip-12.s: Likewise.
bfd/ChangeLog
bfd/elf.c
binutils/testsuite/ChangeLog
binutils/testsuite/binutils-all/objcopy.exp
binutils/testsuite/binutils-all/strip-12.d [new file with mode: 0644]
binutils/testsuite/binutils-all/strip-12.s [new file with mode: 0644]