[hjl@gnu-6 gc-4]$ cat a.s .globl _start _start: .dc.a __start__foo .section _foo,"aw",%progbits foo: .ascii "This is " [hjl@gnu-6 gc-4]$ cat b.s .section _foo,"aw",%progbits .ascii "a test.\0" [hjl@gnu-6 gc-4]$ make gcc -B./ -fdata-sections -c -o a.o a.s gcc -B./ -fdata-sections -c -o b.o b.s ./ld --gc-sections -o x a.o b.o objdump -s -j _foo x x: file format elf64-x86-64 Contents of section _foo: 6000b8 54686973 20697320 This is [hjl@gnu-6 gc-4]$ rm x [hjl@gnu-6 gc-4]$ make LD=ld.gold ld.gold --gc-sections -o x a.o b.o objdump -s -j _foo x x: file format elf64-x86-64 Contents of section _foo: 4010b8 54686973 20697320 61207465 73742e00 This is a test.. [hjl@gnu-6 gc-4]$
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=be83aa76d2877770c23d7c2bde0319564a8f7e48 commit be83aa76d2877770c23d7c2bde0319564a8f7e48 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Oct 23 04:23:51 2015 -0700 Add a test for PR ld/19167 PR ld/19167 * ld-gc/gc.exp: Run pr19167 test. * ld-gc/pr19167.d: New file. * ld-gc/pr19167a.s: Likewise. * ld-gc/pr19167b.s: Likewise.
Now I got Running /export/gnu/import/git/sources/binutils-gdb/ld/testsuite/ld-gc/gc.exp ... FAIL: ld-gc/pr19167
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1cce69b9dc8c58884c3cc4a8928fb234294e6886 commit 1cce69b9dc8c58884c3cc4a8928fb234294e6886 Author: Alan Modra <amodra@gmail.com> Date: Fri Oct 23 22:23:05 2015 +1030 Handle __start_* and __stop_* symbols in --gc-sections PR ld/11133 PR ld/19161 PR ld/19167 * elflink.c (_bfd_elf_gc_mark_hook): Delete code handling __start_* and __stop_* symbol refs. (_bfd_elf_gc_mark_rsec): Add start_stop parameter. Handle __start_* and __stop_* symbol refs here.. (_bfd_elf_gc_mark_reloc): ..and here. * elf-bfd.h (_bfd_elf_gc_mark_hook): Update prototype. * elf-eh-frame.c (_bfd_elf_parse_eh_frame): Update _bfd_elf_gc_mark_rsec call.
Fixed.