bug in ld.so when called via dlopen()

Joakim Tjernlund joakim.tjernlund at transmode.se
Fri Aug 27 14:28:22 UTC 2010


Natanael Copa <natanael.copa at gmail.com> wrote on 2010/08/27 16:11:57:
>
> On Fri, Aug 27, 2010 at 3:06 PM, Joakim Tjernlund
> <joakim.tjernlund at transmode.se> wrote:
> > Natanael Copa <natanael.copa at gmail.com> wrote on 2010/08/27 14:39:50:
> >>
> >> On Fri, Aug 27, 2010 at 9:53 AM, Joakim Tjernlund
> >> <joakim.tjernlund at transmode.se> wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> I have an issue with lua and a lua binding to c-client[1], limap[2].
> >> >> libc-client calls some callback functions supposed to be implemented
> >> >> in the main application.
> >> >>
> >> >> So various mm_* functions are implemented in limap.c as callbacks, for
> >> >> example mm_dlog().
> >> >>
> >> >> But when lua does dlopen() to load the module i get error:
> >> >> lua: symbol 'mm_dlog': can't resolve symbol in lib '/usr/lib/libc-client.so.1'
> >> >>
> >> >> I have simplified testcase here:
> >> >> wget -O - http://dev.alpinelinux.org/~ncopa/uclibc-dlopen-testcase.tar.gz
> >> >> | tar -zxf
> >> >>
> >> >> Both bar and baz works with glibc and bar fails on uclibc. Might be i
> >> >> do something wrong?
> >> >
> >> > Didn't look into your testcase but uClibc differs from glibc w.r.t dependencies.
> >> > You need to have corrected DT_NEEDED entries in your libs that reflect
> >> > the true deps. At least it was like so when I impl. it but I have
> >> > no idea if NPTL changes this.
> >>
> >> might be i'm doing it wrong since phps imap plugin seems to work, and
> >> it is linked to c-client.
> >>
> >> > I think this is required in the specs. but glibc is more forgiving.
> >>
> >> how should the linker flags be then, in my examples?
> >
> > libfoo.so depends on foo_callback which is in plugin.so but
> > libfoo.so does not depend on plugin.so so you need to add
> > plugin.so in libfoo.so's DT_NEEDED
>
> This means that c-client by design wont work with other .so files on
> uclibc and the world needs a properly written imap client C library.
> sigh...

You  could try fixing uClibc dlopen :)
That will make dlopen more complicated, it was much ersier if one
require all deps. It is questionable if it is the right thing to do.

>
> I suppose i can use static c-client library for my lua module.
>
> I wonder how php work around this since it seems to work there?

No idea but I guess they just include all dependant libs when linking.
In this case it is harder since the libs are circular.
It think --as-needed needs all libs too so I guess uClibc is on the right track :)




More information about the uClibc mailing list