On Thu, 3 Dec 1998, Louis Glassy wrote:

> If most binaries really do use only a small fraction of libc (or libfoo,
> whatever), is it appropriate to reorganize the linker to either weed out
> unused calls..

It does do this.  If you have the following lines:

printf("%f %f",sin(a),sin(a));

and you change it to:

printf("%f %f",sin(a),cos(a));

The first example produces code that is 130841 bytes long, the 2nd one 
is 130975 long.  (gcc with -static)  There is an extra 130 bytes added,
because of the inclusion of 'cos' code.

The thing is that some functions depend on others, for example, printf
relies on vfprintf and so on.

>       and the linker looks at required symbols in foo.o, and 
>       behind-the-scenes does this:
> $ ld foo.o /usr/lib/libc/common.o \
>            /usr/lib/libc/stdlib/atoi.o \
>          /usr/lib/libc/stdio/printf.o

The linker then also needs to link in all the functions referred to by
printf, for example strchr, sizeof, abs, strlen, etc.  (Yes, all those
functions are in libc/stdio1/printf.c).

Davey

Reply via email to