delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/11/19/06:54:57

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3BF7A1A5.6090006@enea.se>
Date: Sun, 18 Nov 2001 12:55:17 +0100
From: Mohammad Saleem <mosa AT enea DOT se>
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: cygwin AT cygwin DOT com, crossgcc AT sources DOT redhat DOT com
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 AT enea DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019