Web lists-archives.com

Re: Problem with differences with DLOPEN / DLSYM compared to ubuntu (16.04) / debian (stretch).




On 15.09.2017 06:51, Gary Schneir wrote:
Thanks for the response but I am a little confused by it.  If Cygwin is
supposed to provide POSIX API functionality and DLOPEN / DLSYM are
supported in CYGWIN, then I shouldn't care about the underlying
complexity or restrictions of running within the Windows environment and using DLLs.  The behavior should be the same as in other POSIX environments.

I don't see this behavior on Linux.

This is a transcript from an Ubuntu 16.04 system:

$ txr
This is the TXR Lisp interactive listener of TXR 186.
Quit with :quit or Ctrl-D on empty line. Ctrl-X ? for cheatsheet.
1> (dlopen nil)
#<cptr dlhandle: 480918>
2> (dlsym *1 "cons")
#<cptr dlsym: 0>
3> (dlsym *1 "car")
#<cptr dlsym: 0>
4> (dlsym *1 "cdr")
#<cptr dlsym: 0>
5> (dlsym *1 "malloc")
#<cptr dlsym: b3fd70>
6> (dlsym *1 "printf")
#<cptr dlsym: b12ed0>

The external functions cons, car and cdr in the txr executable
(I assure everyone they are there) cannot be found by dlsym,
but malloc and printf in the linked C library are found.

I.e. the same issue you're having on Cygwin.

Cygwin aims for Linux compatibility more than POSIX. The motto
is "get that Linux feeling on Windows", after all.
It's splashed right below the Cygwin banner here:
https://cygwin.com/

Not finding the executable's own symbol with dlsym (unless
some special arrangements are made to dynamically export
the symbols) looks very much like a "Linux feeling"!

If we run "nm -D" on the executable to see what dynamic symbols
are provided, we find only "_init" and "_fini":

$ nm -D /usr/local/bin/txr | grep T
080fa3cc T _fini
0804a7a4 T _init

and, by golly, these *can* be found with dlsym on the
dlopen(NULL, ...) handle!

7> (dlsym *1 "_fini")
#<cptr dlsym: 80fa3cc>
8> (dlsym *1 "_init")
#<cptr dlsym: 804a7a4>


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