This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: [PATCH] Restore dlsym(RTLD_NEXT, ...) behaviour


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


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