Linking un-referenced function
John Carter
john.carter@tait.co.nz
Tue May 23 00:53:00 GMT 2006
On Mon, 22 May 2006, Jason Lam wrote:
> I looked through the documents and couldn't find an
> option to not link an un-referenced function into the
> final image. Does GCC support it? Could someone
> please help?
Sorry, I got confuddled...
Use
`--gc-sections'
option on linker and...
`-ffunction-sections'
`-fdata-sections'
Place each function or data item into its own section in the output
file if the target supports arbitrary sections. The name of the
function or the name of the data item determines the section's name
in the output file.
Use these options on systems where the linker can perform
optimizations to improve locality of reference in the instruction
space. Most systems using the ELF object format and SPARC
processors running Solaris 2 have linkers with such optimizations.
AIX may have these optimizations in the future.
Only use these options when there are significant benefits from
doing so. When you specify these options, the assembler and
linker will create larger object and executable files and will
also be slower. You will not be able to use `gprof' on all
systems if you specify this option and you may have problems with
debugging if you specify both this option and `-g'.
John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : john.carter@tait.co.nz
New Zealand
Carter's Clarification of Murphy's Law.
"Things only ever go right so that they may go more spectacularly wrong later."
>From this principle, all of life and physics may be deduced.
More information about the Gcc-help
mailing list