dlsym: symbols in dependencies

Yaakov (Cygwin/X) yselkowitz@users.sourceforge.net
Thu Feb 4 08:29:00 GMT 2010


Per POSIX:

"""The dlsym() function shall search for the named symbol in all objects 
loaded automatically as a result of loading the object referenced by 
handle (see dlopen )."""

With the relevant part of dlopen() saying:

"""Note that some implementations permit the construction of 
dependencies between such objects that are embedded within files. In 
such cases, a dlopen() operation shall load such dependencies in 
addition to the object referenced by file."""

IOW, when the target of dlopen() has linked dependencies, not only shall 
those dependencies must also be loaded by dlopen() but the symbols 
therein found by dlsym().  On Cygwin, by the nature of PE/COFF the 
dependencies are loaded, but dlsym() does not search their symbols.

Attached is a STC:

# on Cygwin:
$ gcc -Wl,--export-all-symbols -o dlsym-test.exe dlsym-test.c
$ ./dlsym-test.exe
I can dlopen() myself...
and I can dlsym() myself...
but I can't dlsym() my deps.

# on Linux:
$ gcc -Wl,--export-dynamic -o dlsym-test dlsym-test.c -ldl
$ ./dlsym-test
I can dlopen() myself...
and I can dlsym() myself...
but I can dlsym() my deps!

I have encountered several real-world cases which depends on this behaviour.

TIA,


Yaakov

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dlsym-test.c
URL: <http://cygwin.com/pipermail/cygwin/attachments/20100204/d2a0572a/attachment.c>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list