Subject: Re: dlsym(3) is buggy
To: Jason R Thorpe <>
From: Olaf Seibert <>
List: current-users
Date: 11/08/2000 10:17:22
On Tue 07 Nov 2000 at 19:30:53 -0800, Jason R Thorpe wrote:
> Yah, if you want your program to export symbols to modules, you need
> --export-dynamic.

But that is not my pboblem - maybe I haven't been very clear then.

To illustrate the problem with gpg:

gpg can load modules. Each of those modules exports two symbols, which
identify the modules and their entry points. Thesy are called
gnupgext_version and gnupgext_enum_func.

gpg uses el->handle = dlopen(el->name, RTLD_NOW), then dlsym(el->handle,
"gnupgext_version") to get the symbol gnupgext_version from the module.

Howerver, due to an oversight the symbol gnupgext_version also exists in
the main program, so I never got that symbol from the module. I got the
version from the main program.

Even when I fixed that, for the second module that was loaded I got the
gnupgext_version from the first module.

gpg was already linked with -Wl,-export-dynamic. Removing it made
loading the first module fail:

gpg: /usr/pkg/lib/gnupg/idea: error loading extension: /usr/pkg/lib/gnupg/idea: Undefined PLT symbol "g10_log_fatal" (reloc type = 26, symnum = 38)

then the second module STILL got the wrong symbol:

gpg: /usr/pkg/lib/gnupg/tiger: IDEA ($Revision: 1.11 $)
gpg: /usr/pkg/lib/gnupg/tiger: provides cipher algorithm 1
gpg: loaded cipher 1 (IDEA)

___ Olaf 'Rhialto' Seibert - rhialto@polder    -- Ah only did well at school
\X/       -- tae git intae an O level class tae git away fae Begbie.
Hi! I am a .signature virus. Copy me into your .signature to help me spread.