This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
dlsym bug?
- From: Joe Krahn <jkrahn at nc dot rr dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 24 Apr 2002 07:36:41 -0400
- Subject: 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());
}