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

Jakub Jelinek jakub@redhat.com
Thu May 10 05:50:00 GMT 2001


Hi!

Informix uses dlsym(RTLD_NEXT, "foo") in the main program, which used to
work but does not work any longer.
IMHO dlsym(RTLD_NEXT, "foo") in the main program makes sense, consider
something like:
#define _GNU_SOURCE
#include <dlfcn.h>
int getpid()
{
  return 32;
}
int main(void)
{
  void *p = (void *)getpid;
  void *q = dlsym (RTLD_DEFAULT, "getpid");
  void *r = dlsym (RTLD_NEXT, "getpid");
  printf ("%p %p %p\n", p, q, r);
}
It looks like this was changed when strict map range checking was added to
dl-sym.c. The patch below does not catch all cases where the error could be
signalled, but I think it is better if it works in the main program than to
catch them all (alternatively, the code could e.g. find at least smallest
l_map_start above _dl_loaded->l_map_start and check if caller is less than
that; BTW: why isn't l_map_end for the main program deducted from
Elf_Phdr?).
What is also needed is some variant of either H.J.'s _dl_signal_error or
e.g. the attached one (so that signalling error in real statically linked
application works).

	Jakub


More information about the Libc-hacker mailing list