Bug 18785 - strip is broken
Summary: strip is broken
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-07 15:12 UTC by H.J. Lu
Modified: 2015-08-07 17:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
A testcase (4.67 KB, application/octet-stream)
2015-08-07 16:13 UTC, H.J. Lu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2015-08-07 15:12:44 UTC
On Linux/x86-64,

commit 6e33951edcbed1fd803beabcde2af3b252b92164
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Aug 7 05:04:21 2015 -0700

    Properly merge hidden versioned symbol

gave

# /export/gnu/import/git/sources/gcc/contrib/compare-debug stage2-gcc/compare-elim.o stage3-gcc/compare-elim.o
stage2-gcc/compare-elim.o.stripped stage3-gcc/compare-elim.o.stripped differ: byte 5729, line 9
objdump: stage2-gcc/compare-elim.o.stripped: File format not recognized
objdump: stage3-gcc/compare-elim.o.stripped: File format not recognized
stage2-gcc/compare-elim.o.stripped stage3-gcc/compare-elim.o.stripped differ: byte 5729, line 9
objdump: stage2-gcc/compare-elim.o.stripped: File format not recognized
objdump: stage3-gcc/compare-elim.o.stripped: File format not recognized
objdump: stage2-gcc/compare-elim.o.stripped: File format not recognized
objdump: stage3-gcc/compare-elim.o.stripped: File format not recognized
Comment 1 H.J. Lu 2015-08-07 16:13:42 UTC
Created attachment 8494 [details]
A testcase

[hjl@gnu-6 pr18785]$ make
/bin/strip compare-elim.o -o good.o
./strip compare-elim.o -o bad.o
cmp good.o bad.o
good.o bad.o differ: byte 5729, line 9
Makefile:5: recipe for target 'all' failed
make: *** [all] Error 1
[hjl@gnu-6 pr18785]$
Comment 2 cvs-commit@gcc.gnu.org 2015-08-07 17:37:43 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d4ac1f878ecef58f1e4b4ff0cbfb4b475656eaf4

commit d4ac1f878ecef58f1e4b4ff0cbfb4b475656eaf4
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Aug 7 10:28:42 2015 -0700

    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.
Comment 3 H.J. Lu 2015-08-07 17:45:19 UTC
Fixed.