A problem about dlsym
Joakim Tjernlund
joakim.tjernlund at transmode.se
Wed Sep 24 07:34:10 UTC 2014
"uClibc" <uclibc-bounces at uclibc.org> wrote on 2014/09/24 05:51:08:
>
> Hi,
>
> After I using the dlopen some libs successfully, I tried to use dlsym to
find the symbol.
>
> E.g.
>
> The open order is (liba => libb => libc):
> liba = dlopen("./liba.so", RTLD_LAZY); //liba.so has the aSymbol
> libb = dlopen("./libb.so", RTLD_LAZY); //libb.so has the bSymbol
> libc = dlopen("./libc.so", RTLD_LAZY); //libc.so has the cSymbol
>
> Use dlsym to find the symbol:
> bSymbol = dlsym(liba, "bSymbol")); //we can find the bSymbol and
cSymbol via liba
> cSymbol = dlsym(liba, "cSymbol"));
> aSymbol = dlsym(libb, "aSymbol")); //but, we can not find the
aSymbol via libb or libc
> aSymbol = dlsym(libc, "aSymbol"));
>
> cSymbol = dlsym(libb, "cSymbol")); //we can find the cSymbol via
libb
> bSymbol = dlsym(libc, "bSymbol")); //but, we can not find the
bSymbol via libc
>
> It looks like that we can find all the following symbols via the first
opened handle
> and find all the following symbols except first opened symbols via the
second opened handle, and so on.
>
> Is it a bug or it supposed to act like that ?
I guess this is related to your dependencies: How does lib{a,b,c} depend
on each other?
Do a "readelf -d <lib> | grep NEEDED" and post the result.
Jocke
More information about the uClibc
mailing list