Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2007 20:01:54 -0500
From:      Alexander Kabaev <kabaev@gmail.com>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        freebsd-hackers@freebsd.org, Alejandro Pulver <alepulver@freebsd.org>
Subject:   Re: dlopen: resolving external library symbols to calling program
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>

next in thread | previous in thread | raw e-mail | index | archive | help
--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 <kostikbel@gmail.com> 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 <kostikbel@gmail.com> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071130200154.6de101c5>