[PATCH] Restore dlsym(RTLD_NEXT, ...) behaviour
Jakub Jelinek
jakub@redhat.com
Thu May 10 09:34:00 GMT 2001
On Thu, May 10, 2001 at 08:59:38AM -0700, Ulrich Drepper wrote:
> Andreas Jaeger <aj@suse.de> writes:
>
> > The patch looks fine but I'll leave those for Ulrich to check,
>
> No, the patch makes no sense. The parameter is named RTLD_NEXT not
> without reason. *NEXT* means you have already found one instance.
> You have to use RTLD_DEFAULT for the first search.
But as I've tried to explain in the test, RTLD_DEFAULT gives a different
answer than RTLD_NEXT would even for the main program.
In the test, the main program (= _dl_loaded) provides some symbol, when you
want the next such symbol, you definitely cannot use RTLD_DEFAULT.
A modified example:
#define _GNU_SOURCE
#include <dlfcn.h>
#include <unistd.h>
pid_t getpid(void)
{
pid_t (*f)(void);
f = (pid_t (*)(void)) dlsym (RTLD_NEXT, "getpid");
return f() + 26;
}
pid_t pid;
int main(void)
{
pid = getpid();
}
Jakub
More information about the Libc-hacker
mailing list