dlsym() may return an undefined symbol

Cedric Hombourger chombourger at nexwave-solutions.com
Thu Jan 11 22:15:12 UTC 2007


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/20070111/0f8c8448/attachment-0001.htm 


More information about the uClibc mailing list