About the dll search algorithm of dlopen (patch-r3)

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Aug 31 18:48:00 GMT 2016


On Aug 30 17:56, Michael Haubenwallner wrote:
> Hi Corinna,
> 
> On 08/30/2016 04:51 PM, Corinna Vinschen wrote:
> > On Aug 29 18:50, Michael Haubenwallner wrote:
> >> On 08/26/2016 01:49 PM, Corinna Vinschen wrote:
> >>> On Aug 26 13:18, Corinna Vinschen wrote:
> >>>
> >>> Apart from these minor bits and pieces, I really like this new
> >>> pathfinder class, btw.
> >>
> >> Thank you! :)
> >>
> >> While at it: Combining dlopen thoughts with the "forkables" background
> >> around replacing dlls-in-use leads me to this thought for redundant
> >> calls of dlopen:
> >>
> >> As we've already agreed that GetModuleHandleEx might make sense,
> > 
> > Erm... where exactly did we do that?  I recall I mentioned using
> > LoadLibraryEx with LOAD_LIBRARY_SEARCH_USER_DIRS and the AddDllDirectory
> > functions, but I don't think we talked about GetModuleHandleEx.
> 
> Indeed not for dlopen calls including a path - but for without a path:
> https://sourceware.org/ml/cygwin-developers/2016-06/msg00003.html
> 
> > The question is if it really makes sense to add calls to
> > GetModuleHandleEx.  Apart from slowing down the dlopen call, it seems
> > unnecessary.  Assuming you call LoadLibrary with the same paths and same
> > extensions in the same order, wouldn't a second call to dlopen have the
> > exact same result (loading the same file)?
> 
> Sure - as long as an already loaded dll is not replaced by an updated one.
> Before I'll gonna try: Do you know by chance what LoadLibrary does here?

No, I don't know exactly, but in theory it should try to match
the incoming filename against the filename stored in the loader
list attached to the PEB.  This would even work if the DLL has been
renamed in the meantime.


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/20160831/c4782cc3/attachment.sig>


More information about the Cygwin-developers mailing list