A problem about dlsym

Yang Yingliang yangyingliang at huawei.com
Wed Sep 24 08:44:26 UTC 2014


On 2014/9/24 15:34, Joakim Tjernlund wrote:
> "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
> 
> 
Here is the results:

readelf -d libaa.so | grep NEEDED
 0x00000001 (NEEDED)                     Shared library: [libc.so.0]
readelf -d libbb.so | grep NEEDED
 0x00000001 (NEEDED)                     Shared library: [libc.so.0]
readelf -d libcc.so | grep NEEDED
 0x00000001 (NEEDED)                     Shared library: [libc.so.0]


Regards,
Yang



More information about the uClibc mailing list