|
View:
New views
19 Messages
—
Rating Filter:
Alert me
|
|
|
[Bug binutils/13947] New: Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
Bug #: 13947 Summary: Strip applied twice corrupts binaries compiled with --emit-relocs Product: binutils Version: unspecified Status: NEW Severity: normal Priority: P2 Component: binutils AssignedTo: unassigned@... ReportedBy: binutils-bugs@... Classification: Unclassified I need to produce binaries with --emit-relocs options passed to the linker. After calling strip once on the freshly compiled binary, it runs fine, but after applying strip again, as it sometimes happens in complicated build systems, the binary is corrupted and segfaults. This doesn't happen with binaries compiled without --emit-relocs, in which case strip is idempotent indeed. I tried that with different versions of GCC with both C and C++ programs. I also tried different versions of binutils and x86_64, i386 and arm architectures. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug binutils/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
Alan Modra <amodra at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Target| |x86_64-linux, i686-linux, | |arm-linuxeabi CC| |amodra at gmail dot com --- Comment #1 from Alan Modra <amodra at gmail dot com> 2012-04-08 23:18:17 UTC --- Looks OK on powerpc-linux and powerpc64-linux with current mainline binutils $ gcc -o hello /src/tmp/hello.c -Wl,-q $ ./hello Hello world $ strip hello $ ./hello Hello world $ strip hello $ ./hello Hello world On x86-64 the second strip gives $ strip hello BFD: stY8lcQd: section `.ctors' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stY8lcQd: section `.dtors' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stY8lcQd: section `.jcr' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stY8lcQd: section `.dynamic' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stY8lcQd: section `.got' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stY8lcQd: section `.got.plt' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stY8lcQd: section `.data' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stY8lcQd: section `.bss' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss $ ./hello Segmentation fault -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug binutils/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> 2012-04-09 23:26:02 UTC --- x86-64 backend uses the reloc_count field in .rela.plt section to store the number of relocations it has. It confuses bfd_elf_final_link to set SEC_RELOC on .rela.plt, which leads to erroneous .rela.rela.plt section. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug binutils/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
H.J. Lu <hjl.tools at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hjl.tools at gmail dot com -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug binutils/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> 2012-04-10 00:38:37 UTC --- Created attachment 6333 --> http://sourceware.org/bugzilla/attachment.cgi?id=6333 A patch -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug binutils/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
H.J. Lu <hjl.tools at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |2.23 (HEAD) -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug binutils/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #4 from Ignacy Gawędzki <binutils-bugs at qult dot net> 2012-04-10 07:54:49 UTC --- (In reply to comment #3) > Created attachment 6333 [details] > A patch I just tried this patch and it doesn't seem to fix anything. I rebuilt all of binutils after applying it, rebuild a binary with --emit-relocs using ld from the newly rebuilt binutils and then used the new strip binary. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
H.J. Lu <hjl.tools at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|binutils |ld --- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> 2012-04-10 21:49:59 UTC --- (In reply to comment #4) > (In reply to comment #3) > > Created attachment 6333 [details] > > A patch > > I just tried this patch and it doesn't seem to fix anything. I rebuilt all of > binutils after applying it, rebuild a binary with --emit-relocs using ld from > the newly rebuilt binutils and then used the new strip binary. strip is OK. It is a linker bug. You need to use the new linker to create the executable. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #6 from Ignacy Gawędzki <binutils-bugs at qult dot net> 2012-04-11 11:40:52 UTC --- (In reply to comment #5) > (In reply to comment #4) > > (In reply to comment #3) > > > Created attachment 6333 [details] > > > A patch > > > > I just tried this patch and it doesn't seem to fix anything. I rebuilt all of > > binutils after applying it, rebuild a binary with --emit-relocs using ld from > > the newly rebuilt binutils and then used the new strip binary. > > strip is OK. It is a linker bug. You need to use the new linker to > create the executable. As I said, I tried to link with the ld from the newly rebuilt binutils. To this end, I first created the object file using gcc -c and then looked at the output of gcc -Wl,--emit-relocs -v to know what arguments it passes to collect2. I used the same arguments with the freshly built ld-new binary in the ld/ subdirectory (just changed the path to the object file) to produce the executable. Now I can apply strip once and twice, but the third time it fails with: BFD: stTayZcg: section `.ctors' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stTayZcg: section `.dtors' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stTayZcg: section `.jcr' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stTayZcg: section `.dynamic' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stTayZcg: section `.got' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stTayZcg: section `.got.plt' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stTayZcg: section `.data' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss BFD: stTayZcg: section `.bss' can't be allocated in segment 3 LOAD: .ctors .dtors .jcr .dynamic .got .got.plt .data .bss and the generated binary segfaults. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> 2012-04-11 14:54:19 UTC --- (In reply to comment #6) > (In reply to comment #5) > > (In reply to comment #4) > > > (In reply to comment #3) > > > > Created attachment 6333 [details] > > > > A patch > > > > > > I just tried this patch and it doesn't seem to fix anything. I rebuilt all of > > > binutils after applying it, rebuild a binary with --emit-relocs using ld from > > > the newly rebuilt binutils and then used the new strip binary. > > > > strip is OK. It is a linker bug. You need to use the new linker to > > create the executable. > > As I said, I tried to link with the ld from the newly rebuilt binutils. To > this end, I first created the object file using gcc -c and then looked at the > output of gcc -Wl,--emit-relocs -v to know what arguments it passes to > collect2. I used the same arguments with the freshly built ld-new binary in > the ld/ subdirectory (just changed the path to the object file) to produce the > executable. > > Now I can apply strip once and twice, but the third time it fails with: > Please provide outputs of "readelf -Sl" on each ld/strip result. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #8 from Ignacy Gawędzki <binutils-bugs at qult dot net> 2012-04-11 16:19:13 UTC --- (In reply to comment #7) > Please provide outputs of "readelf -Sl" on each ld/strip result. Sure, here you are. After building the executable: There are 34 section headers, starting at offset 0x1160: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .interp PROGBITS 0000000000400238 00000238 000000000000001c 0000000000000000 A 0 0 1 [ 2] .note.ABI-tag NOTE 0000000000400254 00000254 0000000000000020 0000000000000000 A 0 0 4 [ 3] .note.gnu.build-i NOTE 0000000000400274 00000274 0000000000000024 0000000000000000 A 0 0 4 [ 4] .gnu.hash GNU_HASH 0000000000400298 00000298 000000000000001c 0000000000000000 A 5 0 8 [ 5] .dynsym DYNSYM 00000000004002b8 000002b8 0000000000000060 0000000000000018 A 6 1 8 [ 6] .dynstr STRTAB 0000000000400318 00000318 000000000000003d 0000000000000000 A 0 0 1 [ 7] .gnu.version VERSYM 0000000000400356 00000356 0000000000000008 0000000000000002 A 5 0 2 [ 8] .gnu.version_r VERNEED 0000000000400360 00000360 0000000000000020 0000000000000000 A 6 1 8 [ 9] .rela.dyn RELA 0000000000400380 00000380 0000000000000018 0000000000000018 A 5 0 8 [10] .rela.plt RELA 0000000000400398 00000398 0000000000000030 0000000000000018 A 5 13 8 [11] .init PROGBITS 00000000004003c8 000003c8 0000000000000018 0000000000000000 AX 0 0 4 [12] .rela.init RELA 0000000000000000 000019e0 0000000000000048 0000000000000018 32 11 8 [13] .plt PROGBITS 00000000004003e0 000003e0 0000000000000030 0000000000000010 AX 0 0 16 [14] .text PROGBITS 0000000000400410 00000410 00000000000001d8 0000000000000000 AX 0 0 16 [15] .rela.text RELA 0000000000000000 00001a28 0000000000000228 0000000000000018 32 14 8 [16] .fini PROGBITS 00000000004005e8 000005e8 000000000000000e 0000000000000000 AX 0 0 4 [17] .rela.fini RELA 0000000000000000 00001c50 0000000000000018 0000000000000018 32 16 8 [18] .rodata PROGBITS 00000000004005f8 000005f8 000000000000000a 0000000000000000 A 0 0 4 [19] .eh_frame_hdr PROGBITS 0000000000400604 00000604 000000000000002c 0000000000000000 A 0 0 4 [20] .eh_frame PROGBITS 0000000000400630 00000630 00000000000000a4 0000000000000000 A 0 0 8 [21] .rela.eh_frame RELA 0000000000000000 00001c68 0000000000000048 0000000000000018 32 20 8 [22] .ctors PROGBITS 0000000000600e28 00000e28 0000000000000010 0000000000000000 WA 0 0 8 [23] .dtors PROGBITS 0000000000600e38 00000e38 0000000000000010 0000000000000000 WA 0 0 8 [24] .jcr PROGBITS 0000000000600e48 00000e48 0000000000000008 0000000000000000 WA 0 0 8 [25] .dynamic DYNAMIC 0000000000600e50 00000e50 0000000000000190 0000000000000010 WA 6 0 8 [26] .got PROGBITS 0000000000600fe0 00000fe0 0000000000000008 0000000000000008 WA 0 0 8 [27] .got.plt PROGBITS 0000000000600fe8 00000fe8 0000000000000028 0000000000000008 WA 0 0 8 [28] .data PROGBITS 0000000000601010 00001010 0000000000000010 0000000000000000 WA 0 0 8 [29] .bss NOBITS 0000000000601020 00001020 0000000000000010 0000000000000000 WA 0 0 8 [30] .comment PROGBITS 0000000000000000 00001020 000000000000002a 0000000000000001 MS 0 0 1 [31] .shstrtab STRTAB 0000000000000000 0000104a 0000000000000112 0000000000000000 0 0 1 [32] .symtab SYMTAB 0000000000000000 00001cb0 0000000000000600 0000000000000018 33 46 8 [33] .strtab STRTAB 0000000000000000 000022b0 00000000000001f1 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), l (large) I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) Elf file type is EXEC (Executable file) Entry point 0x400410 There are 9 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040 0x00000000000001f8 0x00000000000001f8 R E 8 INTERP 0x0000000000000238 0x0000000000400238 0x0000000000400238 0x000000000000001c 0x000000000000001c R 1 [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2] LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000 0x00000000000006d4 0x00000000000006d4 R E 200000 LOAD 0x0000000000000e28 0x0000000000600e28 0x0000000000600e28 0x00000000000001f8 0x0000000000000208 RW 200000 DYNAMIC 0x0000000000000e50 0x0000000000600e50 0x0000000000600e50 0x0000000000000190 0x0000000000000190 RW 8 NOTE 0x0000000000000254 0x0000000000400254 0x0000000000400254 0x0000000000000044 0x0000000000000044 R 4 GNU_EH_FRAME 0x0000000000000604 0x0000000000400604 0x0000000000400604 0x000000000000002c 0x000000000000002c R 4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 8 GNU_RELRO 0x0000000000000e28 0x0000000000600e28 0x0000000000600e28 0x00000000000001d8 0x00000000000001d8 R 1 Section to Segment mapping: Segment Sections... 00 01 .interp 02 .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame 03 .ctors .dtors .jcr .dynamic .got .got.plt .data .bss 04 .dynamic 05 .note.ABI-tag .note.gnu.build-id 06 .eh_frame_hdr 07 08 .ctors .dtors .jcr .dynamic .got Then after stripping once: There are 32 section headers, starting at offset 0x1150: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .interp PROGBITS 0000000000400238 00000238 000000000000001c 0000000000000000 A 0 0 1 [ 2] .note.ABI-tag NOTE 0000000000400254 00000254 0000000000000020 0000000000000000 A 0 0 4 [ 3] .note.gnu.build-i NOTE 0000000000400274 00000274 0000000000000024 0000000000000000 A 0 0 4 [ 4] .gnu.hash GNU_HASH 0000000000400298 00000298 000000000000001c 0000000000000000 A 5 0 8 [ 5] .dynsym DYNSYM 00000000004002b8 000002b8 0000000000000060 0000000000000018 A 6 1 8 [ 6] .dynstr STRTAB 0000000000400318 00000318 000000000000003d 0000000000000000 A 0 0 1 [ 7] .gnu.version VERSYM 0000000000400356 00000356 0000000000000008 0000000000000002 A 5 0 2 [ 8] .gnu.version_r VERNEED 0000000000400360 00000360 0000000000000020 0000000000000000 A 6 1 8 [ 9] .rela.dyn RELA 0000000000400380 00000380 0000000000000018 0000000000000018 A 5 0 8 [10] .rela.plt RELA 0000000000400398 00000398 0000000000000030 0000000000000018 A 5 13 8 [11] .init PROGBITS 00000000004003c8 000003c8 0000000000000018 0000000000000000 AX 0 0 4 [12] .rela.init RELA 0000000000000000 00001950 0000000000000000 0000000000000018 0 11 8 [13] .plt PROGBITS 00000000004003e0 000003e0 0000000000000030 0000000000000010 AX 0 0 16 [14] .text PROGBITS 0000000000400410 00000410 00000000000001d8 0000000000000000 AX 0 0 16 [15] .rela.text RELA 0000000000000000 00001950 0000000000000000 0000000000000018 0 14 8 [16] .fini PROGBITS 00000000004005e8 000005e8 000000000000000e 0000000000000000 AX 0 0 4 [17] .rela.fini RELA 0000000000000000 00001950 0000000000000000 0000000000000018 0 16 8 [18] .rodata PROGBITS 00000000004005f8 000005f8 000000000000000a 0000000000000000 A 0 0 4 [19] .eh_frame_hdr PROGBITS 0000000000400604 00000604 000000000000002c 0000000000000000 A 0 0 4 [20] .eh_frame PROGBITS 0000000000400630 00000630 00000000000000a4 0000000000000000 A 0 0 8 [21] .rela.eh_frame RELA 0000000000000000 00001950 0000000000000000 0000000000000018 0 20 8 [22] .ctors PROGBITS 0000000000600e28 00000e28 0000000000000010 0000000000000000 WA 0 0 8 [23] .dtors PROGBITS 0000000000600e38 00000e38 0000000000000010 0000000000000000 WA 0 0 8 [24] .jcr PROGBITS 0000000000600e48 00000e48 0000000000000008 0000000000000000 WA 0 0 8 [25] .dynamic DYNAMIC 0000000000600e50 00000e50 0000000000000190 0000000000000010 WA 6 0 8 [26] .got PROGBITS 0000000000600fe0 00000fe0 0000000000000008 0000000000000008 WA 0 0 8 [27] .got.plt PROGBITS 0000000000600fe8 00000fe8 0000000000000028 0000000000000008 WA 0 0 8 [28] .data PROGBITS 0000000000601010 00001010 0000000000000010 0000000000000000 WA 0 0 8 [29] .bss NOBITS 0000000000601020 00001020 0000000000000010 0000000000000000 WA 0 0 8 [30] .comment PROGBITS 0000000000000000 00001020 000000000000002a 0000000000000001 MS 0 0 1 [31] .shstrtab STRTAB 0000000000000000 0000104a 0000000000000102 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), l (large) I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) Elf file type is EXEC (Executable file) Entry point 0x400410 There are 9 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040 0x00000000000001f8 0x00000000000001f8 R E 8 INTERP 0x0000000000000238 0x0000000000400238 0x0000000000400238 0x000000000000001c 0x000000000000001c R 1 [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2] LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000 0x00000000000006d4 0x00000000000006d4 R E 200000 LOAD 0x0000000000000e28 0x0000000000600e28 0x0000000000600e28 0x00000000000001f8 0x0000000000000208 RW 200000 DYNAMIC 0x0000000000000e50 0x0000000000600e50 0x0000000000600e50 0x0000000000000190 0x0000000000000190 RW 8 NOTE 0x0000000000000254 0x0000000000400254 0x0000000000400254 0x0000000000000044 0x0000000000000044 R 4 GNU_EH_FRAME 0x0000000000000604 0x0000000000400604 0x0000000000400604 0x000000000000002c 0x000000000000002c R 4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 8 GNU_RELRO 0x0000000000000e28 0x0000000000600e28 0x0000000000600e28 0x00000000000001d8 0x00000000000001d8 R 1 Section to Segment mapping: Segment Sections... 00 01 .interp 02 .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame 03 .ctors .dtors .jcr .dynamic .got .got.plt .data .bss 04 .dynamic 05 .note.ABI-tag .note.gnu.build-id 06 .eh_frame_hdr 07 08 .ctors .dtors .jcr .dynamic .got After stripping the second time: There are 32 section headers, starting at offset 0x1150: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .interp PROGBITS 0000000000400238 00000238 000000000000001c 0000000000000000 A 0 0 1 [ 2] .note.ABI-tag NOTE 0000000000400254 00000254 0000000000000020 0000000000000000 A 0 0 4 [ 3] .note.gnu.build-i NOTE 0000000000400274 00000274 0000000000000024 0000000000000000 A 0 0 4 [ 4] .gnu.hash GNU_HASH 0000000000400298 00000298 000000000000001c 0000000000000000 A 5 0 8 [ 5] .dynsym DYNSYM 00000000004002b8 000002b8 0000000000000060 0000000000000018 A 6 1 8 [ 6] .dynstr STRTAB 0000000000400318 00000318 000000000000003d 0000000000000000 A 0 0 1 [ 7] .gnu.version VERSYM 0000000000400356 00000356 0000000000000008 0000000000000002 A 5 0 2 [ 8] .gnu.version_r VERNEED 0000000000400360 00000360 0000000000000020 0000000000000000 A 6 1 8 [ 9] .rela.dyn RELA 0000000000400380 00000380 0000000000000018 0000000000000018 A 5 0 8 [10] .rela.plt RELA 0000000000400398 00000398 0000000000000030 0000000000000018 A 5 13 8 [11] .init PROGBITS 00000000004003c8 000003c8 0000000000000018 0000000000000000 AX 0 0 4 [12] .rela.init RELA 0000000000000000 00001020 0000000000000000 0000000000000018 5 11 8 [13] .plt PROGBITS 00000000004003e0 000003e0 0000000000000030 0000000000000010 AX 0 0 16 [14] .text PROGBITS 0000000000400410 00000410 00000000000001d8 0000000000000000 AX 0 0 16 [15] .rela.text RELA 0000000000000000 00001020 0000000000000000 0000000000000018 5 14 8 [16] .fini PROGBITS 00000000004005e8 000005e8 000000000000000e 0000000000000000 AX 0 0 4 [17] .rela.fini RELA 0000000000000000 00001020 0000000000000000 0000000000000018 5 16 8 [18] .rodata PROGBITS 00000000004005f8 000005f8 000000000000000a 0000000000000000 A 0 0 4 [19] .eh_frame_hdr PROGBITS 0000000000400604 00000604 000000000000002c 0000000000000000 A 0 0 4 [20] .eh_frame PROGBITS 0000000000400630 00000630 00000000000000a4 0000000000000000 A 0 0 8 [21] .rela.eh_frame RELA 0000000000000000 00001020 0000000000000000 0000000000000018 5 20 8 [22] .ctors PROGBITS 0000000000600e28 00000e28 0000000000000010 0000000000000000 WA 0 0 8 [23] .dtors PROGBITS 0000000000600e38 00000e38 0000000000000010 0000000000000000 WA 0 0 8 [24] .jcr PROGBITS 0000000000600e48 00000e48 0000000000000008 0000000000000000 WA 0 0 8 [25] .dynamic DYNAMIC 0000000000600e50 00000e50 0000000000000190 0000000000000010 WA 6 0 8 [26] .got PROGBITS 0000000000600fe0 00000fe0 0000000000000008 0000000000000008 WA 0 0 8 [27] .got.plt PROGBITS 0000000000600fe8 00000fe8 0000000000000028 0000000000000008 WA 0 0 8 [28] .data PROGBITS 0000000000601010 00001010 0000000000000010 0000000000000000 WA 0 0 8 [29] .bss NOBITS 0000000000601020 00001020 0000000000000010 0000000000000000 WA 0 0 8 [30] .comment PROGBITS 0000000000000000 00001020 000000000000002a 0000000000000001 MS 0 0 1 [31] .shstrtab STRTAB 0000000000000000 0000104a 0000000000000102 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), l (large) I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) Elf file type is EXEC (Executable file) Entry point 0x400410 There are 9 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040 0x00000000000001f8 0x00000000000001f8 R E 8 INTERP 0x0000000000000238 0x0000000000400238 0x0000000000400238 0x000000000000001c 0x000000000000001c R 1 [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2] LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000 0x00000000000006d4 0x00000000000006d4 R E 200000 LOAD 0x0000000000000e28 0x0000000000600e28 0x0000000000600e28 0x00000000000001f8 0x0000000000000208 RW 200000 DYNAMIC 0x0000000000000e50 0x0000000000600e50 0x0000000000600e50 0x0000000000000190 0x0000000000000190 RW 8 NOTE 0x0000000000000254 0x0000000000400254 0x0000000000400254 0x0000000000000044 0x0000000000000044 R 4 GNU_EH_FRAME 0x0000000000000604 0x0000000000400604 0x0000000000400604 0x000000000000002c 0x000000000000002c R 4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 8 GNU_RELRO 0x0000000000000e28 0x0000000000600e28 0x0000000000600e28 0x00000000000001d8 0x00000000000001d8 R 1 Section to Segment mapping: Segment Sections... 00 01 .interp 02 .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame 03 .ctors .dtors .jcr .dynamic .got .got.plt .data .bss 04 .dynamic 05 .note.ABI-tag .note.gnu.build-id 06 .eh_frame_hdr 07 08 .ctors .dtors .jcr .dynamic .got And lastly, after the third stripping: There are 32 section headers, starting at offset 0x1f78: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .interp PROGBITS 0000000000400238 00000238 000000000000001c 0000000000000000 A 0 0 1 [ 2] .note.ABI-tag NOTE 0000000000400254 00000254 0000000000000020 0000000000000000 A 0 0 4 [ 3] .note.gnu.build-i NOTE 0000000000400274 00000274 0000000000000024 0000000000000000 A 0 0 4 [ 4] .gnu.hash GNU_HASH 0000000000400298 00000298 000000000000001c 0000000000000000 A 5 0 8 [ 5] .dynsym DYNSYM 00000000004002b8 000002b8 0000000000000060 0000000000000018 A 6 1 8 [ 6] .dynstr STRTAB 0000000000400318 00000318 000000000000003d 0000000000000000 A 0 0 1 [ 7] .gnu.version VERSYM 0000000000400356 00000356 0000000000000008 0000000000000002 A 5 0 2 [ 8] .gnu.version_r VERNEED 0000000000400360 00000360 0000000000000020 0000000000000000 A 6 1 8 [ 9] .rela.dyn RELA 0000000000400380 00000380 0000000000000018 0000000000000018 A 5 0 8 [10] .rela.plt RELA 0000000000400398 00000398 0000000000000030 0000000000000018 A 5 13 8 [11] .init PROGBITS 00000000004003c8 000003c8 0000000000000018 0000000000000000 AX 0 0 4 [12] .rela.init RELA 0000000000000000 00001e48 0000000000000000 0000000000000018 5 11 8 [13] .plt PROGBITS 00000000004003e0 000003e0 0000000000000030 0000000000000010 AX 0 0 16 [14] .text PROGBITS 0000000000400410 00000410 00000000000001d8 0000000000000000 AX 0 0 16 [15] .rela.text RELA 0000000000000000 00001e48 0000000000000000 0000000000000018 5 14 8 [16] .fini PROGBITS 00000000004005e8 000005e8 000000000000000e 0000000000000000 AX 0 0 4 [17] .rela.fini RELA 0000000000000000 00001e48 0000000000000000 0000000000000018 5 16 8 [18] .rodata PROGBITS 00000000004005f8 000005f8 000000000000000a 0000000000000000 A 0 0 4 [19] .eh_frame_hdr PROGBITS 0000000000400604 00000604 000000000000002c 0000000000000000 A 0 0 4 [20] .eh_frame PROGBITS 0000000000400630 00000630 00000000000000a4 0000000000000000 A 0 0 8 [21] .rela.eh_frame RELA 0000000000000000 00001e48 0000000000000000 0000000000000018 5 20 8 [22] .ctors PROGBITS 0000000000600e28 00001c50 0000000000000010 0000000000000000 WA 0 0 8 [23] .dtors PROGBITS 0000000000600e38 00001c60 0000000000000010 0000000000000000 WA 0 0 8 [24] .jcr PROGBITS 0000000000600e48 00001c70 0000000000000008 0000000000000000 WA 0 0 8 [25] .dynamic DYNAMIC 0000000000600e50 00001c78 0000000000000190 0000000000000010 WA 6 0 8 [26] .got PROGBITS 0000000000600fe0 00001e08 0000000000000008 0000000000000008 WA 0 0 8 [27] .got.plt PROGBITS 0000000000600fe8 00001e10 0000000000000028 0000000000000008 WA 0 0 8 [28] .data PROGBITS 0000000000601010 00001e38 0000000000000010 0000000000000000 WA 0 0 8 [29] .bss NOBITS 0000000000601020 00001e48 0000000000000010 0000000000000000 WA 0 0 8 [30] .comment PROGBITS 0000000000000000 00001e48 000000000000002a 0000000000000001 MS 0 0 1 [31] .shstrtab STRTAB 0000000000000000 00001e72 0000000000000102 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), l (large) I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) Elf file type is EXEC (Executable file) Entry point 0x400410 There are 9 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040 0x00000000000001f8 0x00000000000001f8 R E 8 INTERP 0x0000000000000238 0x0000000000400238 0x0000000000400238 0x000000000000001c 0x000000000000001c R 1 [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2] LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000 0x00000000000006d4 0x00000000000006d4 R E 200000 LOAD 0x0000000000001c50 0x0000000000c01c50 0x0000000000600e28 0x00000000000001f8 0x0000000000000208 RW 200000 DYNAMIC 0x0000000000001c78 0x0000000000600e50 0x0000000000600e50 0x0000000000000190 0x0000000000000190 RW 8 NOTE 0x0000000000000254 0x0000000000400254 0x0000000000400254 0x0000000000000044 0x0000000000000044 R 4 GNU_EH_FRAME 0x0000000000000604 0x0000000000400604 0x0000000000400604 0x000000000000002c 0x000000000000002c R 4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 8 GNU_RELRO 0x0000000000001c50 0x0000000000c01c50 0x0000000000600e28 0x00000000000001d8 0x00000000000001d8 R 1 Section to Segment mapping: Segment Sections... 00 01 .interp 02 .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame 03 04 .dynamic 05 .note.ABI-tag .note.gnu.build-id 06 .eh_frame_hdr 07 08 I hope this'll help. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #9 from H.J. Lu <hjl.tools at gmail dot com> 2012-04-11 16:33:50 UTC --- (In reply to comment #8) > (In reply to comment #7) > > Please provide outputs of "readelf -Sl" on each ld/strip result. > > Sure, here you are. After building the executable: > Please provide the executable before strip. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #10 from Ignacy Gawędzki <binutils-bugs at qult dot net> 2012-04-11 18:52:25 UTC --- Created attachment 6335 --> http://sourceware.org/bugzilla/attachment.cgi?id=6335 The executable unstripped This is the executable as output by ld. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #11 from H.J. Lu <hjl.tools at gmail dot com> 2012-04-12 00:33:30 UTC --- The problem is strip removes relocation while keeping an empty relocation section: [hjl@gnu-6 pr13947]$ cat foo.s .text .globl _start _start: .dc.a foo .data .globl foo foo: .byte 20 [hjl@gnu-6 pr13947]$ gcc -c foo.s [hjl@gnu-6 pr13947]$ readelf -r foo.o Relocation section '.rela.text' at offset 0x320 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000000000 000500000001 R_X86_64_64 0000000000000000 foo + 0 [hjl@gnu-6 pr13947]$ strip foo.o [hjl@gnu-6 pr13947]$ readelf -rS foo.o There are 6 section headers, starting at offset 0x70: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .text PROGBITS 0000000000000000 00000040 0000000000000008 0000000000000000 AX 0 0 4 [ 2] .rela.text RELA 0000000000000000 000001f0 0000000000000000 0000000000000018 0 1 8 [ 3] .data PROGBITS 0000000000000000 00000048 0000000000000001 0000000000000000 WA 0 0 4 [ 4] .bss NOBITS 0000000000000000 0000004c 0000000000000000 0000000000000000 WA 0 0 4 [ 5] .shstrtab STRTAB 0000000000000000 0000004c 0000000000000021 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), l (large) I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) There are no relocations in this file. [hjl@gnu-6 pr13947]$ The empty relocation section confuses strip when mapping sections to segments. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #12 from H.J. Lu <hjl.tools at gmail dot com> 2012-04-12 01:07:54 UTC --- Created attachment 6337 --> http://sourceware.org/bugzilla/attachment.cgi?id=6337 A patch This patch removes the empty relocation sections. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #13 from Ignacy Gawędzki <binutils-bugs at qult dot net> 2012-04-12 10:22:55 UTC --- (In reply to comment #12) > Created attachment 6337 [details] > A patch > > This patch removes the empty relocation sections. I confirm that both patches together fix the bug. Thank you very much. =) -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #14 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> 2012-04-13 02:52:39 UTC --- CVSROOT: /cvs/src Module name: src Changes by: hjl@... 2012-04-13 02:52:35 Modified files: binutils : ChangeLog objcopy.c binutils/testsuite: ChangeLog binutils/testsuite/binutils-all/i386: compressed-1b.d compressed-1c.d binutils/testsuite/binutils-all/x86-64: compressed-1b.d compressed-1c.d Log message: Don't generate empty reloc sections binutils/ PR binutils/13947 * objcopy.c (copy_object): Call copy_relocations_in_section before copy_section. (skip_section): New. (copy_relocations_in_section): Likewise. (copy_section): Use skip_section. Don't copy relocations here. binutils/testsuite/ PR binutils/13947 * binutils-all/i386/compressed-1b.d: Remove empty REL section. * binutils-all/i386/compressed-1c.d: Likewise. * binutils-all/x86-64/compressed-1b.d: Remove empty RELA section. * binutils-all/x86-64/compressed-1c.d: Likewise. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/ChangeLog.diff?cvsroot=src&r1=1.1890&r2=1.1891 http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/objcopy.c.diff?cvsroot=src&r1=1.154&r2=1.155 http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/testsuite/ChangeLog.diff?cvsroot=src&r1=1.256&r2=1.257 http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/testsuite/binutils-all/i386/compressed-1b.d.diff?cvsroot=src&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/testsuite/binutils-all/i386/compressed-1c.d.diff?cvsroot=src&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/testsuite/binutils-all/x86-64/compressed-1b.d.diff?cvsroot=src&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/testsuite/binutils-all/x86-64/compressed-1c.d.diff?cvsroot=src&r1=1.3&r2=1.4 -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
--- Comment #15 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> 2012-04-13 23:20:11 UTC --- CVSROOT: /cvs/src Module name: src Changes by: hjl@... 2012-04-13 23:20:01 Modified files: bfd : ChangeLog elflink.c ld/testsuite : ChangeLog ld/testsuite/ld-x86-64: x86-64.exp Added files: ld/testsuite/ld-x86-64: pr13947.d pr13947.s Log message: Set reloc_count to 0 for reloc sections bfd/ 2012-04-13 Alan Modra <amodra@...> PR ld/13947 * elflink.c (bfd_elf_final_link): Set reloc_count to 0 for reloc sections. ld/testsuite/ 2012-04-13 H.J. Lu <hongjiu.lu@...> PR ld/13947 * ld-x86-64/x86-64.exp: Run pr13947. * ld-x86-64/pr13947.d: New file. * ld-x86-64/pr13947.s: Likewise. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5651&r2=1.5652 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.436&r2=1.437 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1513&r2=1.1514 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13947.d.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/pr13947.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/x86-64.exp.diff?cvsroot=src&r1=1.41&r2=1.42 -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
|
|
[Bug ld/13947] Strip applied twice corrupts binaries compiled with --emit-relocshttp://sourceware.org/bugzilla/show_bug.cgi?id=13947
H.J. Lu <hjl.tools at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #16 from H.J. Lu <hjl.tools at gmail dot com> 2012-04-13 23:21:08 UTC --- Fixed. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@... https://lists.gnu.org/mailman/listinfo/bug-binutils |
| Free embeddable forum powered by Nabble | Forum Help |