Date: Thu, 2 May 1996 09:58:40 +0200 (IST) From: Eli Zaretskii To: Kristian H|gsberg Kristensen Cc: djgpp AT delorie DOT com Subject: Re: Size of executable In-Reply-To: Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On 29 Apr 1996, Kristian H|gsberg Kristensen wrote: > It seems to me that the executable file produced by gcc is guite large...? > I compiled the standard "Hello, world"-program, and the output executable > took up 57k, 32k when compiled with the -s option. > > I know that there's got to be this stub-loader, dpmi-interfacing etc. > but does this really take up all this space, or did I just overlook > some switch? What are the options if you want to reduce the size of > the output? The stub loader is very small--a mere 2K. What's taking most of those 32KB is the code that expands (globs) command-line arguments (so you can say ``myprog *.c''), reads and parses the DJGPP.ENV file, and sets up the command-line arguments in the argv[] array. If you don't need any (or all) of these, you can define empty substitutes for a few library functions, which will slash the size of the startup code to about 14K; that makes the smallest program to be 16KB. For details, look in the libc reference, under the functions whose names begin with `__crt0_'. Most non-trivial programs, though, cannot do without at least two of the three features above (filename globbing can be left out more often). But then most non-trivial programs are much too large to consider 30K a significant overhead.