From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 13 21:11:45 2006 Return-Path: X-Original-To: freebsd-hackers@FreeBSD.org Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8457816A402 for ; Thu, 13 Apr 2006 21:11:45 +0000 (UTC) (envelope-from tataz@tataz.chchile.org) Received: from smtp5-g19.free.fr (smtp5-g19.free.fr [212.27.42.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1E87243D49 for ; Thu, 13 Apr 2006 21:11:42 +0000 (GMT) (envelope-from tataz@tataz.chchile.org) Received: from tatooine.tataz.chchile.org (tataz.chchile.org [82.233.239.98]) by smtp5-g19.free.fr (Postfix) with ESMTP id 2263B275CD for ; Thu, 13 Apr 2006 23:11:41 +0200 (CEST) Received: from obiwan.tataz.chchile.org (unknown [192.168.1.25]) by tatooine.tataz.chchile.org (Postfix) with ESMTP id C140A9B847 for ; Thu, 13 Apr 2006 21:12:24 +0000 (UTC) Received: by obiwan.tataz.chchile.org (Postfix, from userid 1000) id 9F7A6405B; Thu, 13 Apr 2006 23:12:24 +0200 (CEST) Date: Thu, 13 Apr 2006 23:12:24 +0200 From: Jeremie Le Hen To: freebsd-hackers@FreeBSD.org Message-ID: <20060413211224.GO71412@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: Subject: linker mysteries X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Apr 2006 21:11:45 -0000 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 >