OpenSSH 3.7.1p2 linked libs

Georg Schwarz geos at epost.de
Sun Feb 15 22:06:48 EST 2004


> > The linker should ignore unnecessary dependancies, shouldn't it?
> 
> It doesn't (on Linux anyway, I suspect it's the same on other systems).

it doesn't on IRIX 5.3 either
 
> That said, it's already tricky to get the library path and link order 
> right on all supported configurations, and I would not like to see it 
> made harder by maintaing different ones for different binaries.

in this particular case I guess it should not be that hard. Have -lgen
not added to LIBS by configure but, say, to LIBGEN. LIBGEN is then either
-lgen or empty. Have LIBGEN added to the sshd link line only (assuming
this is the only place where you use basename, dirname; from my tests it
is).
Similarly for, say, LIBCRYPTO, which you add everywhehe ehere LIBS already
is except for the scp link line. That way you gain a finer granularity
for selecting which libs to actually use.

> 
> Georg, does this cause an actual problem?  libgen is part of the base 

well, things run nonetheless, but of course it is not optimum. libgen
is part of the OS, libcrypto is not. In any case we get unnecessary
dynamic library dependencies. I guess this will at least make binary
startup a bit slower and could add to overall runtime memory consumption.

> OS, right?  Also, there's no noticable difference in size on Linux.
> 
> $ cat hello.c
> #include <stdio.h>
> int main(void) { puts("Hello, world."); }
> $ gcc hello.c -lcrypto
> $ ldd a.out
>          libcrypto.so.4 => /lib/libcrypto.so.4 (0x40028000)
>          libc.so.6 => /lib/libc.so.6 (0x4011f000)
>          libdl.so.2 => /lib/libdl.so.2 (0x40246000)
>          libz.so.1 => /usr/lib/libz.so.1 (0x40249000)
>          /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
> 

lorenz 15% cc hello.c -lgen
lorenz 16% elfdump -Dl a.out


a.out:
                        ***LIBRARY LIST SECTION***
        Name         Time-Stamp           CheckSum   Flags Version
.liblist
        libgen.so    Nov  1 03:20:56 1994 0xe81f4ee2  NONE sgi1.0
        libc.so.1    Nov  1 03:18:58 1994 0x47ba9926  NONE sgi1.0

lorenz 17% cc hello.c -L/usr/local/pkg/lib -lcrypto
lorenz 18% elfdump -Dl a.out


a.out:
                        ***LIBRARY LIST SECTION***
        Name         Time-Stamp           CheckSum   Flags Version
.liblist
        libcrypto.so.300.1 Feb  5 01:16:41 2004 0xb21379bb  NONE 
        libc.so.1    Nov  1 03:18:58 1994 0x47ba9926  NONE sgi1.0

a.out sizes:

with no libs: 13020
with lgen: 13020
with lcrypto: 13116
with both: 13116


-- 
Georg Schwarz    http://home.pages.de/~schwarz/
 geos at epost.de     +49 177 8811442




More information about the openssh-unix-dev mailing list