This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Linking un-referenced function
- From: Jason Lam <jlam555 at yahoo dot com>
- To: "Meissner, Michael" <michael dot meissner at amd dot com>, John Carter <john dot carter at tait dot co dot nz>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 23 May 2006 16:29:46 -0700 (PDT)
- Subject: RE: Linking un-referenced function
This does the trick! Thank you very much for your
help , Michael and John.
Jason
--- "Meissner, Michael" <michael.meissner@amd.com>
wrote:
> The linker option --gc-sections (ie, from the GCC
> command line:
> -ffunction-sections -fdata-sections
> -Wl,--gc-sections
>
> Will do the collection. You need the two -f options
> so that the
> compiler puts each function/data item into a
> separate section, and then
> the --gc-sections option will enable the linker to
> remove any section
> that is not referenced.
>
> --
> Michael Meissner
> AMD, MS 83-29
> 90 Central Street
> Boxborough, MA 01719
>
> -----Original Message-----
> From: gcc-help-owner@gcc.gnu.org
> [mailto:gcc-help-owner@gcc.gnu.org] On
> Behalf Of Jason Lam
> Sent: Tuesday, May 23, 2006 3:35 PM
> To: John Carter
> Cc: gcc-help@gcc.gnu.org
> Subject: Re: Linking un-referenced function
>
> Thanks for the quick response, John.
>
> It looks like these options will arrange the
> functions
> to different sections in the final image but it
> still
> doesn't exclude them. Am I missing something?
>
> Thanks,
>
> Jason
>
> --- John Carter <john.carter@tait.co.nz> wrote:
>
> > 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.
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.com
>
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com