This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: How to stop --gc-sections nukeing all sections?
- To: greyham at research dot canon dot com dot au
- Subject: Re: How to stop --gc-sections nukeing all sections?
- From: Ian Lance Taylor <ian at zembu dot com>
- Date: 5 Apr 2000 10:51:23 -0700
- CC: binutils at sourceware dot cygnus dot com
- References: <20000405034719.02077505E7@brixi.research.canon.com.au>
Date: Wed, 5 Apr 2000 13:47:19 +1000 (EST)
From: greyham@research.canon.com.au (Graham Stoney)
I'm currently using --gc-sections to eliminate dead code from the Linux kernel
for use on embedded systems. I think I just resolved my last problem, which
was that the linker wasn't outputing _any_ data in the output sections,
presumably because there are no external references to any section. Hence, it
garbage collected _everything_, leaving no output section data, and no kernel
:-(.
My hack workaround is to add "-u _start" to LINKFLAGS, which is enough to
stop ld from discarding everything. However, I'm wondering what the approved
method is to prevent --gc-sections from simply discarding everything?
Is there something I can add to the linker command file to achieve this?
It would be nice to be able to turn --gc-sections on and off without having
to add other stuff to LINKFLAGS. I notice the binutils ldscripts don't suffer
from this problem, but I can't see the magic that makes it work.
The binutils ldscripts typically have an implicit -u option from the
ENTRY command.
They also the KEEP command to retain special sections, such as those
holding initialization code for global constructors.
Ian