Bug 19167 - --gc-sections is broken with __start_
Summary: --gc-sections is broken with __start_
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.26
Assignee: Not yet assigned to anyone
Depends on:
Blocks: 21562
  Show dependency treegraph
Reported: 2015-10-23 11:09 UTC by H.J. Lu
Modified: 2017-06-10 13:54 UTC (History)
1 user (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2015-10-23 11:09:33 UTC
[hjl@gnu-6 gc-4]$ cat a.s
.globl _start
	.dc.a	__start__foo
	.section	_foo,"aw",%progbits
	.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]$
Comment 1 cvs-commit@gcc.gnu.org 2015-10-23 11:25:29 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:


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.
Comment 2 H.J. Lu 2015-10-23 11:26:12 UTC
Now I got

Running /export/gnu/import/git/sources/binutils-gdb/ld/testsuite/ld-gc/gc.exp ...
FAIL: ld-gc/pr19167
Comment 3 cvs-commit@gcc.gnu.org 2015-10-23 11:57:34 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:


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.
Comment 4 H.J. Lu 2017-06-10 13:54:19 UTC