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: 6 Apr 2000 08:36:41 -0700
- CC: binutils at sourceware dot cygnus dot com
- References: <20000406075644.575EC3C960@elph.research.canon.com.au>
Date: Thu, 6 Apr 2000 17:56:44 +1000 (EST)
From: greyham@research.canon.com.au (Graham Stoney)
Ian Lance Taylor writes:
> They also the KEEP command to retain special sections, such as those
> holding initialization code for global constructors.
Aha! It's the old undocumented ld script command trick! Thanks Chief!
There is plenty of undocumented stuff in the binutils, but this one
actually is documented in ld.texinfo.
The only problem now is that the linker is _reversing the order_ of all the
functions (each in its own .text.* section, thanks to -ffunction-sections)
from the order in my .c file when it writes them to the output!
For example, arch/ppc/kernel/process.c has functions in the order:
kernel_stack_top
task_top
dump_fpu
enable_kernel_fp
etc
But in the output map, they're in the order:
etc
c00077a8 T enable_kernel_fp
c00077d0 T dump_fpu
c0007820 T task_top
c0007828 T kernel_stack_top
Would any binutils gurus care to speculate on what could cause the linker to
swap the order of functions like this? I'm so close... and yet so far...
Why do you care about the order?
What does your linker script look like? Do you put .text.* in the
.text section? What order are the sections in the input file?
It's possible that the linker will tend to reverse the order of input
sections which are not mentioned in the linker script and which thus
cause their own output section to be created. I'm not sure. I would
normally expect the linker to add explicitly named input sections to
output sections in the order in which they appear in the input files.
If you look at the linker map, you will see the mapping of input
sections to output sections.
Ian