linker mysteries
Jeremie Le Hen
jeremie at le-hen.org
Wed Apr 12 21:51:29 UTC 2006
Hi list,
[ Please Cc: me in your replies as I am not subscribed to this list. ]
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.
Thank you,
--
Jeremie Le Hen
< jeremie at le-hen dot org >< ttz at chchile dot org >
More information about the freebsd-questions
mailing list