I was curios about which libraries and Syscalls are used by my app while its running.So I started to investigate my app with LD_PRELOAD and some "syscalls" like open, access and write.
But while I'm trying to preload dlopen, to find out which libraries are loaded, I got this error: Symbol not found:
void* dlopen(const char *file, int mode){
static void* (*o_dlopen) ( const char *file, int mode )=0;
printf( "dlopen was called\n" );
o_dlopen = (void*(*)(const char *file, int mode))
dlsym(RTLD_NEXT,"dlopen");
return (*o_dlopen)( file, mode );
}
It seems to be that dlsym is not able to find dlopen a second time. I compiled my preloaded *.so file with -ldl and the arm-gcc provided by android NDK. Using -rdynamic does not work either.
The preloading works fine but not for dlopen. Maybe you can help me...
Thanks in advance
Android
dlopen
is offered by the linker, therefore you need to useRTLD_DEFAULT
when looking up thedlopen
symbol from your preloaded library. See: bionic/libdl/libdl.c and bionic/linker/linker.cpp.