From owner-freebsd-questions@FreeBSD.ORG Wed Apr 12 21:51:29 2006 Return-Path: X-Original-To: freebsd-questions@FreeBSD.org Delivered-To: freebsd-questions@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 576A416A402 for ; Wed, 12 Apr 2006 21:51:29 +0000 (UTC) (envelope-from tataz@tataz.chchile.org) Received: from smtp4-g19.free.fr (smtp4-g19.free.fr [212.27.42.30]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9484043D6E for ; Wed, 12 Apr 2006 21:51:28 +0000 (GMT) (envelope-from tataz@tataz.chchile.org) Received: from tatooine.tataz.chchile.org (tataz.chchile.org [82.233.239.98]) by smtp4-g19.free.fr (Postfix) with ESMTP id 530484F1B4 for ; Wed, 12 Apr 2006 23:51:27 +0200 (CEST) Received: from obiwan.tataz.chchile.org (unknown [192.168.1.25]) by tatooine.tataz.chchile.org (Postfix) with ESMTP id F2E359B4C1; Wed, 12 Apr 2006 21:52:07 +0000 (UTC) Received: by obiwan.tataz.chchile.org (Postfix, from userid 1000) id DBFDE405B; Wed, 12 Apr 2006 23:52:07 +0200 (CEST) Date: Wed, 12 Apr 2006 23:52:07 +0200 From: Jeremie Le Hen To: freebsd-questions@FreeBSD.org Message-ID: <20060412215207.GK71412@obiwan.tataz.chchile.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.11 Cc: Jeremie Le Hen Subject: linker mysteries X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Apr 2006 21:51:29 -0000 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 >