dlopen: resolving external library symbols to calling program

Alejandro Pulver alepulver at FreeBSD.org
Fri Nov 30 11:40:43 PST 2007


On Fri, 30 Nov 2007 19:02:01 +0200
Kostik Belousov <kostikbel at gmail.com> wrote:

> On Fri, Nov 30, 2007 at 01:28:58PM -0300, Alejandro Pulver wrote:
> > Hello.
> > 
> > When I was updating the games/deng port, I found it failed at runtime
> > with the following error:
> > 
> > % 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).
> > 
> > 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.
> > 
> > % 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.
> 
> I suspect that you need to link the doomsday binary with the
> --export-dynamic flag. See the info ld for details.
> > 

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20071130/dee5ec51/signature.pgp


More information about the freebsd-hackers mailing list