public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Giant executables.. what am I doing wrong?
@ 2002-10-15  5:31 Ruppert
  0 siblings, 0 replies; 15+ messages in thread
From: Ruppert @ 2002-10-15  5:31 UTC (permalink / raw)
  To: gcc-help


...


> If you run 'nm' on your pre-stripped executable you will see all the
> compiled in functions from the C library and any other libraries. When you
> do a static compile it doesn't just include only the needed function(s), but
> the entire C library .a file. That's why I recommended going with a smaller
> or more base-functionality C library such as newlib.
> 
...

No. The linker will extract the modules from the archive file (.a)
on a "per object" base. Thus if you use strcpy in your program the
module which contains the definition of strcpy (usually strcpy.o)
gets copied from the archive file to your executable. A archive file
is, in fact, only a collection of individual objects pasted together
and augmented by a common table of symbols.

I would also recommend using 'nm'. This provides detailed insight into
what constitutes your executable.


-- D.Ruppert

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: Giant executables.. what am I doing wrong?
@ 2002-10-14 19:00 Dockeen
  0 siblings, 0 replies; 15+ messages in thread
From: Dockeen @ 2002-10-14 19:00 UTC (permalink / raw)
  To: gcc-help

Have you tried to do a "strip" on the exe?

Wayne

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Giant executables.. what am I doing wrong?
@ 2002-10-14 16:49 Michiel Buddingh'
  2002-10-14 17:08 ` Joshua Nye
  2002-10-15  3:53 ` Steve Dondley
  0 siblings, 2 replies; 15+ messages in thread
From: Michiel Buddingh' @ 2002-10-14 16:49 UTC (permalink / raw)
  To: gcc-help

I'm currently trying to write a program for a linux system with limited
memory, and as such I'd like gcc to generate small, statically linked 
executables.

However, if I compile even a simple program like:

int main() { write(2,"Hello world.\n", 13); return 0; }

with the --static option, then strip it with "--strip-all" I get a 
program worth 332 kB(!).

Needless to say, this is not exactly what I want.

I have tried both gcc 2.95 and gcc 3.2, but the results differ only by
a few bytes.

Am I missing something really obvious here?
-- 
		-- Michiel

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

end of thread, other threads:[~2002-10-15 12:31 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-15  5:31 Giant executables.. what am I doing wrong? Ruppert
  -- strict thread matches above, loose matches on Subject: below --
2002-10-14 19:00 Dockeen
2002-10-14 16:49 Michiel Buddingh'
2002-10-14 17:08 ` Joshua Nye
2002-10-14 17:21   ` Michiel Buddingh'
2002-10-14 17:35     ` Joshua Nye
2002-10-14 18:50       ` Michiel Buddingh'
2002-10-15  2:38         ` Claudio Bley
2002-10-15  5:15           ` Michiel Buddingh'
2002-10-15  5:12         ` Joshua Nye
2002-10-15  5:19           ` Joshua Nye
2002-10-15  5:20           ` Michiel Buddingh'
2002-10-15  3:53 ` Steve Dondley
2002-10-15  4:15   ` Claudio Bley
2002-10-15  5:09   ` Michiel Buddingh'

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