On Sun, Feb 15, 2015 at 1:14 PM, Alexander Monakov <amona...@ispras.ru> wrote: > > > On Sun, 15 Feb 2015, Cyd Haselton wrote: > >> On Sun, Feb 15, 2015 at 11:53 AM, Alexander Monakov <amona...@ispras.ru> >> wrote: >> >> Given that info...and in spite of my aforementioned limited knowledge I >> >> went back to take another look at the source and found this in >> >> libfakechroot.c >> >> >> >> /bld/fakechrt/fakechroot-2.16 $ grep -C 4 dlsym src/libfakechroot.c >> >> /* Lazily load function */ >> >> LOCAL fakechroot_wrapperfn_t fakechroot_loadfunc (struct >> >> fakechroot_wrapper * w) >> >> { >> >> char *msg; >> >> if (!(w->nextfunc = dlsym(RTLD_NEXT, w->name))) {; >> >> msg = dlerror(); >> >> fprintf(stderr, "%s: %s: %s\n", PACKAGE, w->name, msg != NULL ? >> >> msg : "unresolved symbol"); >> >> exit(EXIT_FAILURE); >> >> } >> >> >> >> I'm fairly certain I remember reading something about Android and lazy >> >> function loading....how it doesn't handle it well or does so differently >> >> from standard Linux builds. At any rate, I believe the above code is >> >> responsible for those annoying 'fakechroot: undefined reference to dlopen' >> >> errors, so I'll see if I can fix that. >> > >> > In Android's Bionic libc, the implementation of dlopen() resides in the >> > dynamic loader, and not present in libdl.so. >> >> Yet in Android's NDK documentation, they state that in order to use >> dlopen() functionality in native code you must link against libdl and >> include dlfcn.h. Why would this be the case if the dlopen() >> implementation is not in libdl? >> (documentation link: http://www.kandroid.org/ndk/docs/STABLE-APIS.html) > > That's the standard way of using dlopen, i.e. same as you would do it on Linux > with glibc for example. So the link merely says that you can get dlopen the > same way as usual. > > The difference is that Android's libdl only contains stub symbols for > dlopen&co, and the real symbols can be looked up in the dynamic loader. That > RTLD_NEXT does not work for obtaining a pointer for dlopen, as it works on > glibc, is quite unfortunate, and probably a bug in Bionic. > > Alexander
Would it have anything to do with Android's symbol searching method? I.e. a library must be explicitly linked and loaded if needed; on load a library won't look to already loaded libraries to resolve symbols?