This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

dlsym: symbols in dependencies


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


Attachment: dlsym-test.c
Description: Text document

--
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]