RFC: Objcopy --only-keep-debug update

H.J. Lu hjl.tools@gmail.com
Fri Aug 7 17:38:00 GMT 2015


On Fri, Aug 7, 2015 at 8:56 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Aug 4, 2015 at 3:48 AM, Nick Clifton <nickc@redhat.com> wrote:
>> Hi Guys,
>>
>>   Thanks for the comments on the previous patch.  I am attaching a third
>>   iteration of this patch, which I hope will satisfy everyone.  In this
>>   version I have followed Alan's suggestion of detecting the change in
>>   the _bfd_elf_copy_private_bfd_data function, and I have fixed the text
>>   in binutils.texi describing how --only-keep-debug operates.
>>
>>   Any more comments or suggestions ?
>>
>> Cheers
>>   Nick
>>
>> bfd/ChangeLog
>> 2015-08-04  Nick Clifton  <nickc@redhat.com>
>>
>>         * 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.
>>
>> binutils/ChangeLog
>> 2015-08-04  Nick Clifton  <nickc@redhat.com>
>>
>>         * doc/binutils.texi: Document that the --only-keep-debug option
>>         to strip and objcopy preserves the section headers of stripped
>>         sections.
>>
>> binutils/testsuite/ChangeLog
>> 2015-08-04  Nick Clifton  <nickc@redhat.com>
>>
>>         * 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 breaks binutils:
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=18785
>

I checked in this patch to fix it.

-- 
H.J.
---
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.
-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Check-sh_type-sh_flags-sh_addralign-sh_entsize-when-.patch
Type: text/x-patch
Size: 3585 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20150807/5cb31e59/attachment.bin>


More information about the Binutils mailing list