*** SPAM LEVEL 4.448 *** Dynamic linker behaviour difference between Linux, Hurd and FreeBSD

Simon Richter sjr@debian.org
Fri May 3 15:11:00 GMT 2013


Hi,

I'm writing a small preload library to trace pthread_* calls, and am
running into a bit of a chicken-and-egg problem.

In order to find the original function, I use dlsym(RTLD_NEXT, ...) to
look up the symbol on the first invocation. On Linux, this works find,
however on the Hurd and on FreeBSD, the libdl invokes pthread_once,
which is then dispatched into my preload library, where I still haven't
found the real function.

This could be due to a difference in dlsym() implementation (so it is
sheer luck that it works on Linux), or a true behavioural difference
between platforms.

In any case, I am wondering if it is actually possible to redirect the
pthread_* functions in this way, or if a different approach is required.

LD_DEBUG=all output is attached for Linux (good) and FreeBSD (bad).
Program source[1] is also available.

   Simon

[1] http://www.hogyros.de/download/mutextrace-0.1.2.tar.gz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: good.bz2
Type: application/octet-stream
Size: 5362 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-help/attachments/20130503/b114eb88/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bad.bz2
Type: application/octet-stream
Size: 5908 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-help/attachments/20130503/b114eb88/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 380 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/libc-help/attachments/20130503/b114eb88/attachment.sig>


More information about the Libc-help mailing list