dlsym(RTLD_NEXT) and weak symbols

Maxim Sobolev sobomax at FreeBSD.org
Wed Oct 8 21:36:51 UTC 2008


Hi,

I am not sure if it has even worked correctly, but calling 
dlsym("dlopen", RTLD_NEXT) returns reference to the dlopen() function in 
the libc, not reference to dlopen() function in the ld-elf.so. The 
attempt to call this function then fails, since dlopen() in libc is just 
a stub to make static linking happy.

#pragma weak dlopen
void *
dlopen(const char *name, int mode)
{
         _rtld_error(sorry);
         return NULL;
}

IMHO this is incorrect and is probably part of the bigger problem. The 
dlsym(3) should return first non-weak symbol instead.

-Maxim



More information about the freebsd-current mailing list