From: gvaughan@oranda.demon.co.uk (Gary V. Vaughan)
Subject: another patch for dlopen [was Re: dlopen bug!]
12 Nov 1998 08:22:54 -0800
Message-ID: <36498DA3.72173F70.cygnus.gnu-win32@oranda.demon.co.uk>
References: <36481BE9.35E38846@uz.kuleuven.ac.be>
Mime-Version: 1.0
Content-Type: multipart/mixed;
 boundary="------------976F33BF685023FCC77CE066"
To: Geoffrey Noer <noer@cygnus.com>,
        Jorrit Tyberghein <Jorrit.Tyberghein@uz.kuleuven.ac.be>
Cc: gnu-win32@cygnus.com

This is a multi-part message in MIME format.
--------------976F33BF685023FCC77CE066
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

In another thread, I wrote:
>
> [[wrt my previous patch]] Interestingly, this doesn't
> seem to fix my particular problem.

Jorrit Tyberghein wrote:
> 
> It seems that dlopen always returns the same handle even if used on
> different dll libraries. 

Aha!  *That* is my "particular problem" too.  A fix is attached.  This
is in addition to the previous patch (and the patch from Christian
Jullien).

I forgot to post a ChangeLog entry yesterday, so I have included both
here, and another for Christian's dlsym patch which is attached too.

Cheers,
	Gary.

1998-11-11  Gary V. Vaughan  <gvaughan@oranda.demon.co.uk>

	* dlfcn.cc (get_full_path_of_dll):  the static return value
	used to be returned unchanged on second and subsequent calls.
	It is now correctly reset on each call.

1998-11-10  Christian Jullien <Eligis@wanadoo.fr>

	* dlfcn.cc (dlsym): returns a handle to the named symbol in
	the loaded executable if a null pointer is passes in for
	the module handle.

1998-11-10  Gary V. Vaughan  <gvaughan@oranda.demon.co.uk>

	* dlfcn.cc (dlopen): returns a handle to the executable if
	a null pointer is passed in as the module name.
--------------976F33BF685023FCC77CE066
Content-Type: text/plain; charset=us-ascii;
 name="dlsym-cj-19981110"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="dlsym-cj-19981110"

--- dlfcn.cc.orig	Tue Nov 10 11:58:45 1998
+++ dlfcn.cc	Wed Nov 11 13:09:55 1998
@@ -139,7 +153,12 @@ dlopen (const char *name, int)
 void *
 dlsym (void *handle, const char *name)
 {
-  void *ret = (void *) GetProcAddress (handle, name);
+  void * ret = 0;
+
+  if( handle )
+        ret = (void *) GetProcAddress (handle, name);
+  else  ret = (void *) GetProcAddress (GetModuleHandle(), name);
+
   if (!ret)
     set_dl_error ("dlsym");
   debug_printf ("ret %p", ret);

--------------976F33BF685023FCC77CE066
Content-Type: text/plain; charset=us-ascii;
 name="dlopen-gvv-19981111"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="dlopen-gvv-19981111"

--- dlfcn.cc.orig	Tue Nov 10 11:58:45 1998
+++ dlfcn.cc	Wed Nov 11 13:09:55 1998
@@ -76,6 +76,8 @@ get_full_path_of_dll (const char* str)
   // first check if leading "/" or "\"
   if (name[0] == '/' || name[0] == '\\')
     ret = name;
+  else
+    ret = 0;
 
   // current directory
   if (!ret)

--------------976F33BF685023FCC77CE066--

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
