[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Eliminating static binaries (Was: Unwanted RPM dependencies)

Patrice Dumas wrote:
On Wed, Jun 06, 2007 at 08:41:26AM -0500, Chris Adams wrote:
You should probably test that before you post.  I would say this is the
smallest possible regular C program:

$ cat x.c
int main ()
	return 0;
$ gcc -o x-dyn x.c
$ gcc -static -o x-stat x.c
$ strip x-dyn x-stat
$ ls -l x-dyn x-stat
-rwxr-xr-x 1 cmadams users   2816 Jun  6 08:38 x-dyn
-rwxr-xr-x 1 cmadams users 459492 Jun  6 08:38 x-stat
I don't forsee a static executable being smaller than a dynamic
executable in the real world.  It is possible that somebody could
hand-build (e.g. no gcc, ld, etc.) such an executable, but that doesn't
really count (since that isn't done in the real world).

given that the dynamic executable is 2816 bytes, the static one could be smaller, however it is way bigger. In fact it seems to me (but I don't
rerally know a lot about those things, I was only saying something I saw
elsewhere) that it is way too bigger for that difference to be explained by static linking, there is something else happening there.

I believe the granularity of the linker is a single object file. So even if you use just a small routine within a big object file, the whole thing is linked with (if you think about how ld works internally and what it has to do, it makes sense).

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]