Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Apr 2006 23:12:24 +0200
From:      Jeremie Le Hen <jeremie@le-hen.org>
To:        freebsd-hackers@FreeBSD.org
Subject:   linker mysteries
Message-ID:  <20060413211224.GO71412@obiwan.tataz.chchile.org>

next in thread | raw e-mail | index | archive | help
Hi list,

(I got no answer on freebsd-questions@, thus I give a try here.)

I was doing some testing on shared dependencies and fiddling libfetch's
Makefile for this aim.

I set LDFLAGS to "-v" in order to see the command executed for th
linking.

In the standard Makefile, we have this :
% .if !defined(NO_CRYPT) && !defined(NO_OPENSSL)
% CFLAGS+=        -DWITH_SSL
% DPADD=          ${LIBSSL} ${LIBCRYPTO}
% LDADD=          -lssl -lcrypto
% .endif

And the resulting linker command is : 
% /usr/bin/ld -V -Bshareable -o libfetch.so.4 /usr/lib/crti.o /usr/lib/crtbeginS.o -L/usr/lib -x -soname libfetch.so.4 file.So http.So ftp.So common.So fetch.So -lssl -lcrypto -lgcc_pic -lgcc_pic /usr/lib/crtendS.o /usr/lib/crtn.o

Dependencies are normal :
% jarjarbinks# cd /usr/obj/usr/src/lib/libfetch
% jarjarbinks# ldd libfetch.so
% libfetch.so:
%         libssl.so.4 => /usr/lib/libssl.so.4 (0x3277d000)
%         libcrypto.so.4 => /lib/libcrypto.so.4 (0x3215f000)

If I comment out the variable assignements :
% .if !defined(NO_CRYPT) && !defined(NO_OPENSSL)
% #CFLAGS+=        -DWITH_SSL
% #DPADD=          ${LIBSSL} ${LIBCRYPTO}
% #LDADD=          -lssl -lcrypto
% .endif

The resulting linker command is now :
% /usr/bin/ld -V -Bshareable -o libfetch.so.4 /usr/lib/crti.o /usr/lib/crtbeginS.o -L/usr/lib -x -soname libfetch.so.4 file.So http.So ftp.So common.So fetch.So -lgcc_pic -lgcc_pic /usr/lib/crtendS.o /usr/lib/crtn.o

As you can see, we don't have "-lssl -lcrypto" any more.  However, ldd(1)
still says that libfetch.so is linked against those libraries :
% jarjarbinks# ldd libfetch.so
% libfetch.so:
%         libssl.so.4 => /usr/lib/libssl.so.4 (0x2c72e000)
%         libcrypto.so.4 => /lib/libcrypto.so.4 (0x2cd74000)

Only linking addresses change, but they do at every compilation.

I would be glad if someone could explain why this happens.

Regards,
-- 
Jeremie Le Hen
< jeremie at le-hen dot org >< ttz at chchile dot org >



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060413211224.GO71412>