Bug 64042 - dlsym open symbols from dependency libraries
dlsym open symbols from dependency libraries
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
i386 Linux
medium Severity low
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2002-04-24 07:47 EDT by Joe Krahn
Modified: 2016-11-24 10:17 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-12-15 15:02:06 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Joe Krahn 2002-04-24 07:47:24 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.78 [en] (X11; U; Linux 2.4.9-21 i686)

Description of problem:
If you dlopen a library, dlsym will successfully return
a pointer to symbols from not just the opened lib, but
any dependency libs. This may be more a feature than bug.
IRIX's dlsym will only return symbols from the dlopened
lib. I think that's how it is supposed to work.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. printf("XNextEvent via libGL=%x\n",
    dlsym(dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL ), "XNextEvent"));

Actual Results:  XNextEvent via GL=4021d564

Expected Results:  XNextEvent via GL=0

Additional info:

It doesn't matter which dlopen flags I use. I can even get at
_dl_init from /lib/ld-linux.so.6, which is a second level of
dependency via libc.so.

Here is a simple example test code:

#include <dlfcn.h>
#include <stdio.h>

int main(int argc, char *argv[]){

    void *GL_handle, *func;

    GL_handle = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL );
    printf("GL Handle=%x [dlerror=%s]\n",GL_handle,dlerror());

    func = dlsym(GL_handle, "XNextEvent");
    printf("XNextEvent via GL =%x [dlerror=%s]\n",func,dlerror());

    func = dlsym(GL_handle, "_dl_init");
    printf("_dl_init via GL =%x [dlerror=%s]\n",func,dlerror());

Comment 1 Joe Krahn 2002-04-25 08:33:40 EDT
Checking some docs from LSB, dlopen is supposed load dependency
libraries, but it never defines whether dlsym should return symbols
from those dependency libraries. So that could be just a feature
that differs by OS.

The problem that does exist is that objects opened with
RTLD_LOCAL are globally available, so you get the same result
as when using RTLD_GLOBAL. This doesn't interefere with typical
dlopen usage, so it's only a minor problem.
Comment 2 Joe Krahn 2002-05-06 22:31:02 EDT
I think this is NOTABUG. I checked and found that RTLD_GLOBAL/LOCAL
differences work OK. Availability of symbols in dependent objects is
different from IRIX, but I think IRIX is wrong.

However, it would be helpful to explain this in the man page.
Here's an example from the HP dlsym manpage that agrees w/ Linux:
  dlsym searches for the named symbol in all shared objects loaded
  automatically as a result of loading the object referenced by handle
  (see dlopen(3c)).

Note You need to log in before you can comment on or make changes to this bug.