From owner-freebsd-hackers@FreeBSD.ORG Sat Dec 1 01:27: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 0A39D16A468 for ; Sat, 1 Dec 2007 01:27:43 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.240]) by mx1.freebsd.org (Postfix) with ESMTP id B22ED13C4DD for ; Sat, 1 Dec 2007 01:27:42 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: by an-out-0708.google.com with SMTP id c14so622243anc for ; Fri, 30 Nov 2007 17:27:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer:mime-version:content-type; bh=rSL0hGoUERL8EgDyzDy2Ek1XLu+b0UIlnOLQAFhZL80=; b=s/NN2wPP6URevz5Jtb4nJEfkO4PJW4gj+CZaBlQDy+1pKGkUV7T9TYj88fKc3X87FvV6UmLNsoUiamIi87dMMiy48wgC3d60fLkxDsxP4ZMOuHV3w60Q12k81/MZQOAok6EMnEDulIv8dEjGknIt5Bf7u82GOL52st/Y8aXlNqg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=received:date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer:mime-version:content-type; b=lUkIlVlAhogbdHeLm/6JB767BRTUNDeufwBmp7+n5r3wHY1gqwAzUJ17EHwHJtccyDQ/n9hatk7pqpLNb3fmZtnAa0Ts2N+Bveiuyjjoi/fPfyEEMHWZ2Q1fBDg40wOSmJcnLS8lg+MQoFVIA+spbjMGw5dkJq6IbR3sO+3q+bA= Received: by 10.100.247.14 with SMTP id u14mr15503017anh.1196470926821; Fri, 30 Nov 2007 17:02:06 -0800 (PST) Received: from kan.dnsalias.net ( [24.218.183.247]) by mx.google.com with ESMTPS id 7sm6341086wrl.2007.11.30.17.02.05 (version=SSLv3 cipher=OTHER); Fri, 30 Nov 2007 17:02:05 -0800 (PST) Date: Fri, 30 Nov 2007 20:01:54 -0500 From: Alexander Kabaev To: Kostik Belousov Message-ID: <20071130200154.6de101c5@kan.dnsalias.net> In-Reply-To: <20071130201948.GL83121@deviant.kiev.zoral.com.ua> References: <20071130132858.1e4290a0@deimos.mars.bsd> <20071130170201.GK83121@deviant.kiev.zoral.com.ua> <20071130164033.24b430c9@deimos.mars.bsd> <20071130201948.GL83121@deviant.kiev.zoral.com.ua> X-Mailer: Claws Mail 3.0.2 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/SkiWdhuyO5nnCa4kpUGNMqj"; protocol="application/pgp-signature"; micalg=PGP-SHA1 Cc: freebsd-hackers@freebsd.org, Alejandro Pulver 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: Sat, 01 Dec 2007 01:27:43 -0000 --Sig_/SkiWdhuyO5nnCa4kpUGNMqj Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Fri, 30 Nov 2007 22:19:48 +0200 Kostik Belousov wrote: > On Fri, Nov 30, 2007 at 04:40:33PM -0300, Alejandro Pulver wrote: > > On Fri, 30 Nov 2007 19:02:01 +0200 > > Kostik Belousov wrote: > >=20 > > > 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 > >=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. > >=20 > > I found the following article which briefly describes it (though > > it's for Solaris): > > http://blogs.sun.com/ali/entry/inside_elf_symbol_tables > The ELF specification is freely available, and contains at least the > neccessary minimum of information. The object format has evolved > since then. >=20 > Sun' Linkers and Loaders Guide also contain a lot of useful > information, applicable to any ELF platform. > >=20 > > 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 > I remember it was me. >=20 > > 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? >=20 > I do not know of any such facility in GNU ld. You may limit the > exported symbols by using the version script. But, by default, no > symbols are exported for executable (for shared object, reverse is > true, all symbols are exported). Just a small correction: by default, linker _does_ export symbols from main application, just not all of them. Only symbols that satisfy references from shared libraries passed to linker on command line at binary creation time are exported. -- Alexander Kabaev --=20 Alexander Kabaev --Sig_/SkiWdhuyO5nnCa4kpUGNMqj Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFHULKDQ6z1jMm+XZYRAor5AJ9Rmb5PQDdN5YgV2XUGqR3AviK/rwCguWEQ fWQ1JSImfmQPAG9ImfjD4CQ= =Q9+h -----END PGP SIGNATURE----- --Sig_/SkiWdhuyO5nnCa4kpUGNMqj--