This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

dlsym bug?


If I dlopen a library, dlsym will return pointers to
symbols not only from the dlopened lib, but from any
of it's dependency libraries. I don't think it is
supposed to work that way. IRIX, for example, won't
return dependency lib symbols.

Example code follows. It dlopens libGL, and is then
able to access XNextEvent from libX11, and even
_dl_init from ld-linux.so.6, which is loaded by libc.
It doesn't matter which dlopen flags are used.

Is this a bug or feature? Is it gcc or glibc?

Thanks, Joe Krahn


#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());

}


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