Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <3BF9791F.2070606@enea.se> Date: Mon, 19 Nov 2001 22:26:55 +0100 From: Mohammad Saleem User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.2) Gecko/20010726 Netscape6/6.1 X-Accept-Language: en-us MIME-Version: 1.0 To: kai DOT ruottu AT luukku DOT com CC: crossgcc AT sources DOT redhat DOT com, cygwin AT cygwin DOT com Subject: Re: linking application with a library References: <21558852 DOT 1006167645775 DOT JavaMail DOT hip-pop AT porkkana> <3BF970D8 DOT B1F67C3B AT luukku DOT com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi Kai, Thanks for answer. regards /Mohammad Kai Ruottu wrote: >Mohammad Saleem wrote: > >>Hi all, >> >>I am using h8300-hitachi-hms-gcc cross-complier for building my application. >>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. >> > > The linker shouldn't take anything from the lib if it doesn't need anything >from it. > >>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. >> > > Is the library produced using C++ or ObjC or from where the name 'method' >comes? > >>Now my question is which flag should I use to build mylib.a so that only >>those functions are linked which are being called. >> > > Compiling each function into its own '.o' module is the normal practice, >the linker takes only the needed '.o' files from the archive. > > >>If no function is called then linking mylib.a shouldn't affect the size >>of my application. >> > > Yes, this should be the case... > > BTW, the H8/300 is a architecture which requires tricks like using >the '__attribute__((eightbit_data))' for the SFRs (I/O-registers) in >order to produce any effective code... For instance: > >-------------------- clip -------------------------------- >#define SFR __attribute__((eightbit_data)) > >extern volatile unsigned char SFR SCI_SSR0; >extern volatile unsigned char SFR SCI_TDR0; > >/* >#define SCI_TDR0 (*(volatile unsigned char *) (0xffffdb)) >#define SCI_SSR0 (*(volatile unsigned char *) (0xffffdc)) >*/ > >/* Single char out to the serial port */ > >void put_ser(unsigned char c) >{ > while ((SCI_SSR0 & 0x80) != 0x80) > ; > SCI_TDR0 = c; > SCI_SSR0 &= 0x7F; >} >-------------------- clip -------------------------------- >; GCC For the Hitachi H8/300 >; By Hitachi America Ltd and Cygnus Support >; release F-1 >; -O2 > > .h8300s > .file "put_ser.c" > .section .text > .align 1 > .global _put_ser >_put_ser: >.L5: > mov.b @_SCI_SSR0:8,r2l > and #128,r2l > beq .L5 > mov.b r0l,@_SCI_TDR0:8 > bclr #7,@_SCI_SSR0:8 > rts > .end >-------------------- clip -------------------------------- > > Getting a RISC-like 'load/and/store' operation instead of the >'bclr #7,@_SCI_SSR0:8' is not rare if not using any of these >'tricks'... And if the I/O-ports are used much, much 'code >bloat' will be the result... > >Cheers, Kai > > > -- 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/