From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13103 invoked by alias); 23 May 2006 23:29:52 -0000 Received: (qmail 13094 invoked by uid 22791); 23 May 2006 23:29:52 -0000 X-Spam-Check-By: sourceware.org Received: from web31706.mail.mud.yahoo.com (HELO web31706.mail.mud.yahoo.com) (68.142.201.186) by sourceware.org (qpsmtpd/0.31) with SMTP; Tue, 23 May 2006 23:29:50 +0000 Received: (qmail 78976 invoked by uid 60001); 23 May 2006 23:29:46 -0000 Message-ID: <20060523232946.78974.qmail@web31706.mail.mud.yahoo.com> Received: from [128.107.236.186] by web31706.mail.mud.yahoo.com via HTTP; Tue, 23 May 2006 16:29:46 PDT Date: Tue, 23 May 2006 23:29:00 -0000 From: Jason Lam Subject: RE: Linking un-referenced function To: "Meissner, Michael" , John Carter Cc: gcc-help@gcc.gnu.org In-Reply-To: <6096959DEF5C9447A6BF80BDC7EB9EDC02A448DE@SBOSEXMB1.amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-05/txt/msg00232.txt.bz2 This does the trick! Thank you very much for your help , Michael and John. Jason --- "Meissner, Michael" 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 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