From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 462 invoked by alias); 22 Nov 2001 04:35:26 -0000 Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@sources.redhat.com Received: (qmail 346 invoked from network); 22 Nov 2001 04:35:21 -0000 Received: from unknown (HELO sohm.kpit.com) (203.129.230.82) by sourceware.cygnus.com with SMTP; 22 Nov 2001 04:35:21 -0000 Received: from anitak ([172.10.16.141]) by sohm.kpit.com with Microsoft SMTPSVC(5.0.2195.2966); Thu, 22 Nov 2001 10:05:22 +0530 Message-ID: <004501c1730e$6c2c1810$8d100aac@stpp.soft.net> From: "anitak" To: "Mohammad Saleem" , , References: <3BF7A1A5.6090006@enea.se> Subject: Re: linking application with a library Date: Wed, 14 Nov 2001 19:24:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 X-OriginalArrivalTime: 22 Nov 2001 04:35:22.0515 (UTC) FILETIME=[190E3630:01C1730F] X-SW-Source: 2001-11/txt/msg00849.txt.bz2 Hi Mohammad, The --gc-sections remove unwanted section. But I think it is implemented only for ELF for some targets. For hms it does not work. Try with h8300-elf-ld. Regards, Anita Kulkarni ----- Original Message ----- From: Mohammad Saleem To: ; Sent: Sunday, November 18, 2001 5:25 PM Subject: Re: linking application with a library > Hi David, > > Thanks for your input. > > I tried with the flags you mentioned in your mail like: > > # how to compile C source > %.o: %.c > @echo compiling $< > $(CC) -ffunction-sections -fdata-sections $(CFLAGS) $(INCLUDE) $< > -o $@ > > Even with link I tried with a flag --gc-sections (found by searching in > mail archives) like: > > test.srec: $(OBJ) appcon.o > $(LD) --gc-sections $(LDFLAGS) $^ mylib.a $(LIBS) -o $@ > > > > But still I get the same size of srec as before, i.e my application is > increased by the size of mylib.a even without any function call from > mylib.a, along with a number of warnings like: > > ******************************************** > compiling appcon.c > h8300-hitachi-hms-ld: warning: no memory region specified for section > `._init' > h8300-hitachi-hms-ld: warning: no memory region specified for section > `.configu' > h8300-hitachi-hms-ld: warning: no memory region specified for section > `.timerIn' > ************************************************* > > What am I doing something wrong? > > regards > > /Mohammad > > > > David Korn wrote: > > >>-----Original Message----- > >>From: Mohammad Saleem [mailto:mosa@enea.se] > >>Sent: 18 November 2001 10:36 > >> > > > > > >>I have a lib mylib.a (20 kb) which I want to link with my application. > >>My application gets 20 kb bigger as soon as I link it with mylib.a > >>without any function being called from mylib.a. > >>It seems to me that I have built mylib.a so that the whole lib > >>is linked > >>during linking process even if no one method is being called. > >>Now my question is which flag should I use to build mylib.a so > >>that only > >>those functions are linked which are being called. > >>If no function is called then linking mylib.a shouldn't affect > >>the size > >>of my application. > >> > > > > Alas, the linker is fairly dumb, and can only include or exclude parts > >of a lib file on the basis of the section name (.text, .data or .bss). > > > > Fortunately the compiler is fairly smart, and has an option > >-ffunction-sections that puts every function in a different section. This > >should supposedly do the job you wish. > > > > DaveK > > > > > > > ------ > Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ > Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com > -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ From mboxrd@z Thu Jan 1 00:00:00 1970 From: "anitak" To: "Mohammad Saleem" , , Subject: Re: linking application with a library Date: Wed, 21 Nov 2001 20:35:00 -0000 Message-ID: <004501c1730e$6c2c1810$8d100aac@stpp.soft.net> References: <3BF7A1A5.6090006@enea.se> X-SW-Source: 2001-11/msg01437.html Message-ID: <20011121203500.xUXgGO6cOnkM1UD46EJE275M85JarT6JBA8EUJWteB8@z> Hi Mohammad, The --gc-sections remove unwanted section. But I think it is implemented only for ELF for some targets. For hms it does not work. Try with h8300-elf-ld. Regards, Anita Kulkarni ----- Original Message ----- From: Mohammad Saleem To: ; Sent: Sunday, November 18, 2001 5:25 PM Subject: Re: linking application with a library > Hi David, > > Thanks for your input. > > I tried with the flags you mentioned in your mail like: > > # how to compile C source > %.o: %.c > @echo compiling $< > $(CC) -ffunction-sections -fdata-sections $(CFLAGS) $(INCLUDE) $< > -o $@ > > Even with link I tried with a flag --gc-sections (found by searching in > mail archives) like: > > test.srec: $(OBJ) appcon.o > $(LD) --gc-sections $(LDFLAGS) $^ mylib.a $(LIBS) -o $@ > > > > But still I get the same size of srec as before, i.e my application is > increased by the size of mylib.a even without any function call from > mylib.a, along with a number of warnings like: > > ******************************************** > compiling appcon.c > h8300-hitachi-hms-ld: warning: no memory region specified for section > `._init' > h8300-hitachi-hms-ld: warning: no memory region specified for section > `.configu' > h8300-hitachi-hms-ld: warning: no memory region specified for section > `.timerIn' > ************************************************* > > What am I doing something wrong? > > regards > > /Mohammad > > > > David Korn wrote: > > >>-----Original Message----- > >>From: Mohammad Saleem [ mailto:mosa@enea.se ] > >>Sent: 18 November 2001 10:36 > >> > > > > > >>I have a lib mylib.a (20 kb) which I want to link with my application. > >>My application gets 20 kb bigger as soon as I link it with mylib.a > >>without any function being called from mylib.a. > >>It seems to me that I have built mylib.a so that the whole lib > >>is linked > >>during linking process even if no one method is being called. > >>Now my question is which flag should I use to build mylib.a so > >>that only > >>those functions are linked which are being called. > >>If no function is called then linking mylib.a shouldn't affect > >>the size > >>of my application. > >> > > > > Alas, the linker is fairly dumb, and can only include or exclude parts > >of a lib file on the basis of the section name (.text, .data or .bss). > > > > Fortunately the compiler is fairly smart, and has an option > >-ffunction-sections that puts every function in a different section. This > >should supposedly do the job you wish. > > > > DaveK > > > > > > > ------ > Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ > Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com > -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/