From owner-freebsd-hackers@FreeBSD.ORG Fri Nov 30 19:40:43 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64D7216A468 for ; Fri, 30 Nov 2007 19:40:43 +0000 (UTC) (envelope-from alepulver@FreeBSD.org) Received: from relay00.pair.com (relay00.pair.com [209.68.5.9]) by mx1.freebsd.org (Postfix) with SMTP id 1E7B513C44B for ; Fri, 30 Nov 2007 19:40:42 +0000 (UTC) (envelope-from alepulver@FreeBSD.org) Received: (qmail 38672 invoked by uid 0); 30 Nov 2007 19:40:40 -0000 Received: from unknown (HELO deimos.mars.bsd) (unknown) by unknown with SMTP; 30 Nov 2007 19:40:40 -0000 X-pair-Authenticated: 200.127.53.54 Date: Fri, 30 Nov 2007 16:40:33 -0300 From: Alejandro Pulver To: Kostik Belousov Message-ID: <20071130164033.24b430c9@deimos.mars.bsd> In-Reply-To: <20071130170201.GK83121@deviant.kiev.zoral.com.ua> References: <20071130132858.1e4290a0@deimos.mars.bsd> <20071130170201.GK83121@deviant.kiev.zoral.com.ua> X-Mailer: Claws Mail 3.0.2 (GTK+ 2.12.1; i386-portbld-freebsd6.2) Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/xbiA5QBxBKaAD//kmVKMGtT"; protocol="application/pgp-signature"; micalg=PGP-SHA1 Cc: freebsd-hackers@freebsd.org Subject: Re: dlopen: resolving external library symbols to calling program 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: Fri, 30 Nov 2007 19:40:43 -0000 --Sig_/xbiA5QBxBKaAD//kmVKMGtT Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Fri, 30 Nov 2007 19:02:01 +0200 Kostik Belousov wrote: > On Fri, Nov 30, 2007 at 01:28:58PM -0300, Alejandro Pulver wrote: > > Hello. > >=20 > > When I was updating the games/deng port, I found it failed at runtime > > with the following error: > >=20 > > % doomsday > > While opening dynamic library > > /usr/local/lib/libdropengl.so: > > /usr/local/lib/libdropengl.so: Undefined symbol "ArgExists" > > DD_InitDGL: Loading of libdropengl.so failed. > > (null). > >=20 > > The function is defined in m_args.c which is included in both > > "doomsday" and "libdropengl.so". But nm(1) reports it as undefined for > > "libdropengl.so". Also, it is loaded with RTLD_NOW. > >=20 > > % nm `which doomsday` | grep ArgExists > > 080d9ef0 T ArgExists > You are looking at the wrong symbol table. ELF objects have the dynamic > symbol table that is used during run-time linking, and symbol table used > by the static linker ld. The former table is shown by nm -D. >=20 > I suspect that you need to link the doomsday binary with the > --export-dynamic flag. See the info ld for details. > >=20 It worked, thank you very much. I am reading some books that explain the basics of COFF/ELF formats (like Write Great Code Volume 2: Thinking Low-Level, Writing High-Level), but didn't know about the dynamic symbol table. I found the following article which briefly describes it (though it's for Solaris): http://blogs.sun.com/ali/entry/inside_elf_symbol_tables Now that I remember, the games/quakeforge port had the same problem. But someone fixed it by referencing the symbol (it was only one function) with a function pointer so it got exported in the dynamic table. In this case, could that be done with "-u symbol" when linking the executable, or it isn't possible to export a symbol with linker parameters? Thanks and Best Regards, Ale --Sig_/xbiA5QBxBKaAD//kmVKMGtT Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFHUGcxiV05EpRcP2ERAhp0AJ9xulMK3Df79nNM4JuAbbHmCqUkRACeNJvH KO36PTc0tFLarVJ09ivNAmw= =Er4l -----END PGP SIGNATURE----- --Sig_/xbiA5QBxBKaAD//kmVKMGtT--