This is the mail archive of the cygwin@sourceware.cygnus.com 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]

another patch for dlopen [was Re: dlopen bug!]


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.
--- 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);
--- 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)

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