dlsym() may return an undefined symbol

Joakim Tjernlund joakim.tjernlund at transmode.se
Thu Jan 11 23:05:55 UTC 2007


Please don't post non plain text emails.
 
.27 is rather old and much has happened since then in ld.so.
 
your "fix" is broken. Can you repeat this with .28/or SVN ? If so, enable SUPPORT_LD_DEBUG and
run your test app. with LD_DEBUG=all defined 
 
Have you verified that this works as you expect on a glibc based system?
 
 Jocke
 



  _____  

From: uclibc-bounces at uclibc.org [mailto:uclibc-bounces at uclibc.org] On Behalf Of Cedric Hombourger
Sent: den 11 januari 2007 23:15
To: uclibc at uclibc.org
Subject: dlsym() may return an undefined symbol



Hello there,

With a program similar to the one below, we have observed that dlsym of uclibc 0.9.27 may return the wrong function pointer:

librt = dlopen ("librt.so", RTLD_LAZY);
libc  = dlopen ("libc.so", RTLD_LAZY);

malloc1 = dlsym (libc, "malloc");
res1 = malloc1 (16); // this one is ok, malloc() is called

malloc2 = dlsym (librt, "malloc");
res2 = malloc2 (16); // Ouch the stub for malloc from librt.so / section .MIPS.stubs is returned!

After tracing _dl_find_hash, I noticed the following test which I don't understand:

if (type_class & (sym->st_shndx == SHN_UNDEF)) continue;

I did not understand the meaning of the type_class parameter and why it should be non-zero for undefined symbols to be ignored (and
BTW dlsym() calls _dl_find_hash with a zero type_class value).

Changing the suspect line to:

if ((sym->st_shndx == SHN_UNDEF)) continue;

seem to have fixed the issue but frankly, I am not sure whether this does not cause other issues.

I fairly new to uclibc, any help/comment would be highly appreciated.

Note: it seems that this piece of code wasn't changed in the latest snapshots - right?

Regards,
Cedric Hombourger
NexWave Solutions (www.nexwave-solutions.com)



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/uclibc/attachments/20070112/95c323d7/attachment-0001.htm 


More information about the uClibc mailing list