lkml.org 
[lkml]   [1996]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subjectlibc, smart linking, binary size (elf/a.out)
Date

salam,

well, I know this aint a kernel issue, but I dunno if there's a libc list
(and don't want to look :-) ... so forgive me for being ignorant.

I compiled a rather small piece of code, hardly a full A4 page. I use
two libc functions, "gethostbyname" and "gethostbyaddr".

surprise, surprise, on an elf-system , the binary size is 160KB !!!!
on another machine, a a.out system, the binary size is 14KB.
jesus christ ...

nm shows that a lot of code is included in this binary, that I don't use
at all. YP, for instance (yp_all, yp_bind, yp_first..) and "xdr", I don't
know what this is. xdr_memcreate, and so on ... quite a lot of stuff
for a little DNS-query!

and here's a related question:

o How can one use "smart linking" with static libraries ?

assume the following code:

> t1.c:
>
> void gna() { printf("gna\n"); }
> void bot() { printf("bot\n"); }

> main.c:
>
> void main() { gna(); }

now we do:

> cc -c t1.c
> ar rcv libt1.a t1.c
> cc -o gna main.c -L./ -lt1

now doing a "nm gna" will show that "bot" is a defined symbol of type T.

does that mean that "gna" contains the all the code for "bot", allthough
"bot" is never used ? a waste of space!
is there a switch to tell "ld" to kick out code for unused external references ?

/herp



\
 
 \ /
  Last update: 2005-03-22 13:36    [W:0.099 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site