public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: linking application with a library
@ 2001-11-11  8:26 David Korn
  0 siblings, 0 replies; 9+ messages in thread
From: David Korn @ 2001-11-11  8:26 UTC (permalink / raw)
  To: 'Mohammad Saleem'; +Cc: crossgcc, cygwin

-----Original Message-----
>From: Mohammad Saleem [mailto:mosa@enea.se]
>Sent: 18 November 2001 11:46

  Hiya Mohammad, I can see a couple of things here:

>Even with link I tried with a flag --gc-sections 

  D'oh, yes, sorry, I should have mentioned that one.

>test.srec: $(OBJ) appcon.o
>    $(LD) --gc-sections $(LDFLAGS)   $^ mylib.a $(LIBS) -o $@

  But you are linking mylib.a as if it were an object file!  I think it
needs to be supplied with a -l flag to be treated as a library, does it
not ?  Try renaming mylib.a to libmylib.a (ld requires the name to be in
the format libXXXX.a and then you use -lXXXX), and then try using the
ld line in the makefile like

>    $(LD) --gc-sections $(LDFLAGS)   $^ -lmylib -L. $(LIBS) -o $@

 - ie we tell it that we want the library mylib, it knows then to look for
'libmylib.a', and the -L. tells it that the lib may be found in the 
current directory.

>********************************************
>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'
>*************************************************

  This may reflect a problem with the srec format limiting the length of
section name strings, but see if it goes away when you try the new flags.

       DaveK
--
Burn your ID card!  http://www.optional-identity.org.uk/
Help support the campaign, copy this into your .sig!


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.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/

^ permalink raw reply	[flat|nested] 9+ messages in thread
* linking application with a library
@ 2001-11-11  8:26 Mohammad Saleem
  2001-11-11  8:26 ` vipin aravind
  0 siblings, 1 reply; 9+ messages in thread
From: Mohammad Saleem @ 2001-11-11  8:26 UTC (permalink / raw)
  To: crossgcc, cygwin

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.
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.

Thanks for help.

regards
/Mohammad


--
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/

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: linking application with a library
@ 2001-11-11  8:26 Mohammad Saleem
  2001-11-14 19:24 ` anitak
  0 siblings, 1 reply; 9+ messages in thread
From: Mohammad Saleem @ 2001-11-11  8:26 UTC (permalink / raw)
  To: cygwin, crossgcc

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
>




--
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/

^ permalink raw reply	[flat|nested] 9+ messages in thread
* RE: linking application with a library
@ 2001-11-11  8:26 David Korn
  0 siblings, 0 replies; 9+ messages in thread
From: David Korn @ 2001-11-11  8:26 UTC (permalink / raw)
  To: 'Mohammad Saleem', crossgcc, cygwin

>-----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
-- 
Burn your ID card!  http://www.optional-identity.org.uk/
Help support the campaign, copy this into your .sig!


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.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/

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-11-22  4:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <21558852.1006167645775.JavaMail.hip-pop@porkkana>
2001-11-12  2:47 ` linking application with a library Kai Ruottu
2001-11-12  5:12   ` Mohammad Saleem
2001-11-11  8:26 David Korn
  -- strict thread matches above, loose matches on Subject: below --
2001-11-11  8:26 Mohammad Saleem
2001-11-11  8:26 ` vipin aravind
2001-11-11  8:26 Mohammad Saleem
2001-11-14 19:24 ` anitak
2001-11-21 20:35   ` anitak
2001-11-11  8:26 David Korn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).