This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: _dlfcn_hook and SHARED


On Mon, Jul 21, 2008 at 5:58 PM, Mathieu Lacage
<mathieu.lacage@sophia.inria.fr> wrote:
> while trying to go through the glibc dlfcn/elf source code, I stumbled
> upon the _dlfcn_hook global variable defined in dlfcn/dlerror.c: this
> pointer is initialized to zero (nocommon attribute) and is tested
> extensively at the start of each of the __dlfoo functions for equality
> to NULL when the macro SHARED is defined.
>
> I have, however, been unable to find anywhere this pointer would be
> reset to anything but NULL when SHARED is defined. This begs the
> question: where is _dlfcn_hook ever set to anything but NULL when SHARED
> is defined ?

A statically compiled application will have a copy of all the dl* functions.

If that statically compiled application tries to dlopen a shared
object, there are *may* be two copies of all the dl* functions (and
two copies of the data).

The only way to make this work is to force the newly loaded second
copy of the functions to call back into the static versions.

This song-and-dance allows glibc to support dlopen'd NSS modules from
statically linked applications.

Someone else can correct me if I'm wrong :-)

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]