What does ld.so do that dlopen don't do when loading shared libraries

Celelibi celelibi@gmail.com
Sun Apr 28 21:09:00 GMT 2013


Hello there,

This is my first message to this mailing list. ^^

And I have a question that may be quite unusual: What does ld.so do
that dlopen don't do when loading shared libraries?

A bit of explanation may be needed. There is a profiler named TAU
<tau.uoregon.edu> which can instrument files it compiles and then
generate a file profile.0.0.0 when the program is run. Much like
compiling with gcc -pg.

And I can do things like: compile a shared library with tau_cc (which
instrument the shared object) and then link it with a simple program.
tau_cc.sh -shared -fPIC -o foo.so foo.c
gcc -o sep sep.c foo.so

This works fine, running ./sep produce the profile trace. (That
wouldn't work with gprof.)

However, if I dlopen/dlsym the library instead of linking against it,
it doesn't produce any file.
tau_cc.sh -shared -fPIC -o foo.so foo.c
gcc -o dyn dyn.c


Therefore I guess ld.so does something special when it loads the
needed library that dlopen doesn't do. I think about ctor/entrypoint
execution, but I have no clue to find out.

I join foo.c sep.c and dyn.c as an example.
I can also provide the generated binaries if requested.


PS: I really can't link against the library since the whole
application is designed as components. All the main program does is
loading and running .so following a given xml file.


Best regards,
Celelibi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.c
Type: text/x-csrc
Size: 403 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-help/attachments/20130428/1da551f1/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sep.c
Type: text/x-csrc
Size: 55 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-help/attachments/20130428/1da551f1/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dyn.c
Type: text/x-csrc
Size: 258 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-help/attachments/20130428/1da551f1/attachment-0002.bin>


More information about the Libc-help mailing list