About the dll search algorithm of dlopen

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Jun 1 11:09:00 GMT 2016


On Jun  1 08:40, Michael Haubenwallner wrote:
> Hi,
> 
> two issues with dlopen here (I'm about to prepare patches):
> 
> *) The algorithm to combine dll file name variants with the search path
>    entries needs to be reordered, as in:
>    - for each dll file name variant:
>    -   for each search path:
>    + for each search path entry:
>    +   for each dll file name variant:
>          check if useable

Rationale?  We only need to find one version of the file and there
usually only is one.  This is mainly for moduled systems like perl,
python, etc.  However, if you can speed up the search process ignore the
question...

> *) The directory of the current main executable should be searched
>    after LD_LIBRARY_PATH and before /usr/bin:/usr/lib.
>    And PATH should be searched before /usr/bin:/usr/lib as well.

Checking the executable path and $PATH are Windows concepts.  dlopen
doesn't do that on POSIX systems and we're not doing that either.

Having said that, LoadLibrary will search the usual paths.  After 2.5.2,
we're leaving XP/2003 behind, and then we probably should tighten the
search algorithm along the lines of

  AddDllDirectory ("/usr/bin");
  AddDllDirectory ("/usr/lib");
  [...]
  LoadLibraryEx (path, NULL, LOAD_LIBRARY_SEARCH_USER_DIRS
			     | LOAD_LIBRARY_SEARCH_SYSTEM32);

>    For consistency, IMO, when any searched path ends in either
>    x/bin or x/lib, we should search x/bin:x/lib.

This might make sense, at least in the direction lib->bin.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20160601/fc7f2bdb/attachment.sig>


More information about the Cygwin-developers mailing list