tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: dlopen interception on libasan

On 11/30/16 01:32, Christos Zoulas wrote:
Well, the problem in PR/51670 is that with -fsanitizer=address the
dlopen interception is broken. provides its own dlopen()
and then tries to find the real dlopen using dlsym(RTLD_NEXT,
"dlopen"). That does not work for NetBSD because dlopen in libc is
just a stub (that perhaps should abort), and the real dlopen is in
ld.elf_so itself. Unfortunately we can't get to it anymore easily
because RTLD_DEFAULT, RTLD_SELF, RTLD_NEXT, NULL all return the
wrong dlopen().

Are you sure about RTLD_DEFAULT?

zoom$ cat foo.c
#include <dlfcn.h>

void *
        return dlsym(RTLD_DEFAULT, "dlopen");

void *
        return dlsym(RTLD_NEXT, "dlopen");
zoom$ cat main.c
#include <stdio.h>

void *foo_rtld_default();
void *foo_rtld_next();

        printf("dlopen using default %p\n", foo_rtld_default());
        printf("dlopen using next    %p\n", foo_rtld_next());

zoom$ cc -fPIC -c foo.c -o foo.pico
zoom$ cc -shared -o foo.pico
zoom$ gcc main.c
zoom$ gcc main.c -R$(pwd)
zoom$ ./a.out
dlopen using default 0x7f7ff7c0623a
dlopen using next    0x7f7ff7068c90

That said, I wonder if RTLD_NEXT should work here...

RTLD_DEFAULT/_rtld_symlook_default does the right thing because of

Maybe something similar should be added for RTLD_{SELF,NEXT} here:


Home | Main Index | Thread Index | Old Index