This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: But it is cygwin related.

A C program is going to want to pull in at least a C run-time
(crt0 is one common name for that link file).  Consider this
minimal C program:

extern void exit(int);

void main (int argc, char **argv) {

It is 73 bytes as a .c file and 408 bytes in a .o.
It I link it, doing what gcc defaultly does, the
resulting file is 49750 bytes.  (This is all under
cygwin, with gcc 4.5.3.

It *dynamically* links to:

Windows/SysWOW/ntdll.dll = 1292080 bytes
Windows/syswow64/kernel32.dll = 1114112 bytes
Windows/syswow64/KERNELBASE.dll = 274944 bytes
cygwin1.dll = 2858355 bytes

So, the program itself is small, but potentially has access
to many resources through these dlls that are shared with
other programs.

I guess I don't see what your objection is regarding size
of things, unless you feel 49750 is "too darn much".  Ok,
so after I strip the program to remove symbol info needed
only when debugging, the size is 4622.

By running with gcc -v, I see it links in:

crt0.o =
crtbegin.o =
crtend.o =

and scans the C libraries for things my program, or these, call.
This includes linkage (at least) to malloc/free, etc., needed in
the startup and shutdown, I believe.

Now I add:

#include <stdio.h>

and, in main,


Unstripped the size is a little bigger, 50188.  Stripped
it is (guess what): 4622 bytes.  ldd shows that it will
use the same dynamically linked dlls as the original.

So I'm struggling to see what it is you want / expect here.
The dlls get shared in memory between programs, and once
stripped, the programs can be quite small -- depending on
what you use.  And even if you code directly to Windows
interfaces and use some other tool suite, you will end up
with the Windows dlls in any case, since that's how you
talk to the OS to get anything done.

Regards -- Eliot Moss

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]