Linking un-referenced function

John Carter
Tue May 23 00:49: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?

Tends to occur at the linker script level...

>From the ld info file...

Input Section and Garbage Collection

When link-time garbage collection is in use (`--gc-sections'), it is
often useful to mark sections that should not be eliminated.  This is
accomplished by surrounding an input section's wildcard entry with
`KEEP()', as in `KEEP(*(.init))' or `KEEP(SORT_BY_NAME(*)(.ctors))'.

John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email :
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