Subject: Re: Crosscompile linking questions
To: Anders =?iso-8859-1?Q?Nyg=E5rd?= <anders.nygard@netinsight.net>
From: Richard Earnshaw <rearnsha@arm.com>
List: port-arm32
Date: 07/04/2001 13:48:43
> > The following code:
> > 
> > int m(){
> >   static char c[100000];
> > }
> > 
> > int main(int argc, char **argv){
> >   m();
> > }
> > 
> > generates an executable size of 76104.
> > 
> > nm generates a list of 285 lines (enclosed).
> 
> 
> Ah!  I think I understand.   The compiler is creating the executable using 
> crt0.o, when for a static link it should probably be using scrt0.o.   
> crt0.o contains the dl.. functions which in turn link in the printf 
> functions which then brings in half of libc.
> 
> 
> Try using gcc -v to get the link command. Then copy the link line and 
> change crt0.o to scrt0.o
> 

Manually add -static to the compile command.  Eg

gcc -static -o testprog foo.c

This should change the link command as I suggested.

R.