public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Qn regarding building an application of smallest size for ARM-11 using gcc
@ 2006-06-27  4:22 Binesh
  2006-06-27  6:18 ` Ingo Krabbe
  0 siblings, 1 reply; 3+ messages in thread
From: Binesh @ 2006-06-27  4:22 UTC (permalink / raw)
  To: gcc-help

Hi,

We are trying to build an application for ARM-11 using gcc and the
related auto make suite) that would occupy minimal size.

After adding the -Os and -mthumb we noticed that the size of the
stripped executable with a dependency on libc.so and libz.so was about
87K.
However, when we statically linked it the stripped size grew to 510 K.
We removed all code that uses any of string library or stdio and
instead use only system calls such as ioctl, read, write, mmap and
munmap. (verified using the symbol dumped out by readelf)
Despite this the size remains at 510K.
Trying to link with -nostdlib fails as it refers to undefined
reference to ioctl, read, write, mmap and munmap.
Trying to link with -nostartfiles brought down the size to only 502K.

Do the sys call routines need std libs to be linked in?
Is there an alternative to reduce the size of the statically linked
exe? (Assuming that it might be difficult to migrate all code to asm)

Would appreciate some help / guidance on this. In case there is
another forum/ list which would better annswer these question, please
fwd me to the same.

Thanks!
-Binesh

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

* Re: Qn regarding building an application of smallest size for ARM-11 using gcc
  2006-06-27  4:22 Qn regarding building an application of smallest size for ARM-11 using gcc Binesh
@ 2006-06-27  6:18 ` Ingo Krabbe
  2006-06-27  8:48   ` Andrew Haley
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Krabbe @ 2006-06-27  6:18 UTC (permalink / raw)
  To: gcc-help; +Cc: Binesh

Am Dienstag, 27. Juni 2006 06:22 schrieb Binesh:
> Hi,
>
> We are trying to build an application for ARM-11 using gcc and the
> related auto make suite) that would occupy minimal size.
>
> After adding the -Os and -mthumb we noticed that the size of the
> stripped executable with a dependency on libc.so and libz.so was about
> 87K.
> However, when we statically linked it the stripped size grew to 510 K.
> We removed all code that uses any of string library or stdio and
> instead use only system calls such as ioctl, read, write, mmap and
> munmap. (verified using the symbol dumped out by readelf)
> Despite this the size remains at 510K.
> Trying to link with -nostdlib fails as it refers to undefined
> reference to ioctl, read, write, mmap and munmap.
> Trying to link with -nostartfiles brought down the size to only 502K.
>
> Do the sys call routines need std libs to be linked in?
> Is there an alternative to reduce the size of the statically linked
> exe? (Assuming that it might be difficult to migrate all code to asm)
>
> Would appreciate some help / guidance on this. In case there is
> another forum/ list which would better annswer these question, please
> fwd me to the same.
>
> Thanks!
> -Binesh

I think you have a libc.so problem.  This means, you are using glibc, which 
really is no emebedded solution library.  You should think about using 
smaller libraries that better fit you purpose.  I found a nice page that 
lists some solutions:

http://penguinppc.org/embedded/howto/library.html

bye ingo

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

* Re: Qn regarding building an application of smallest size for ARM-11 using gcc
  2006-06-27  6:18 ` Ingo Krabbe
@ 2006-06-27  8:48   ` Andrew Haley
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Haley @ 2006-06-27  8:48 UTC (permalink / raw)
  To: Binesh; +Cc: gcc-help

Ingo Krabbe writes:
 > Am Dienstag, 27. Juni 2006 06:22 schrieb Binesh:

 > > We are trying to build an application for ARM-11 using gcc and the
 > > related auto make suite) that would occupy minimal size.
 > >
 > > After adding the -Os and -mthumb we noticed that the size of the
 > > stripped executable with a dependency on libc.so and libz.so was about
 > > 87K.
 > > However, when we statically linked it the stripped size grew to 510 K.
 > > We removed all code that uses any of string library or stdio and
 > > instead use only system calls such as ioctl, read, write, mmap and
 > > munmap. (verified using the symbol dumped out by readelf)
 > > Despite this the size remains at 510K.

Don't guess why.  Try linking with -Wl,-Map,app.map

This will give you a map file that tells you exactly why everything
gets linked.

 > > Trying to link with -nostdlib fails as it refers to undefined
 > > reference to ioctl, read, write, mmap and munmap.
 > > Trying to link with -nostartfiles brought down the size to only 502K.
 > >
 > > Do the sys call routines need std libs to be linked in?
 > > Is there an alternative to reduce the size of the statically linked
 > > exe? (Assuming that it might be difficult to migrate all code to asm)

Can't you just use a small asm version of those syscalls?  You've got
source for glibc, so writing the syscalls should only take a few
hours.

Andrew.

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

end of thread, other threads:[~2006-06-27  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-27  4:22 Qn regarding building an application of smallest size for ARM-11 using gcc Binesh
2006-06-27  6:18 ` Ingo Krabbe
2006-06-27  8:48   ` Andrew Haley

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