This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Android native build of GCC

On Sun, 15 Feb 2015, Cyd Haselton wrote:

> On Sun, Feb 15, 2015 at 11:53 AM, Alexander Monakov <> 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 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
> 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:

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.


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