* dcrt0.cc (cygwin__cxa_atexit): Fetch correct DSO handle value

by searching dll list.  Explain why.
This commit is contained in:
Corinna Vinschen 2014-11-07 08:33:22 +00:00
parent 85907fe082
commit 3daf2dc4f1
2 changed files with 13 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2014-11-07 Corinna Vinschen <corinna@vinschen.de>
* dcrt0.cc (cygwin__cxa_atexit): Fetch correct DSO handle value
by searching dll list. Explain why.
2014-11-06 Corinna Vinschen <corinna@vinschen.de> 2014-11-06 Corinna Vinschen <corinna@vinschen.de>
* dcrt0.cc (cygwin_atexit): Change preceeding comment to reflect * dcrt0.cc (cygwin_atexit): Change preceeding comment to reflect

View File

@ -1239,15 +1239,17 @@ do_exit (int status)
calls to __cxa_atexit using the *address* of __dso_handle as DSO handle. calls to __cxa_atexit using the *address* of __dso_handle as DSO handle.
So what we do here is this: A call to __cxa_atexit from the application So what we do here is this: A call to __cxa_atexit from the application
actually calls cygwin__cxa_atexit. From the dso_handle value we fetch the actually calls cygwin__cxa_atexit. From dso_handle (which is either
ImageBase address, which is then used as the actual DSO handle value in &__dso_handle, or __dso_handle == ImageBase or NULL) we fetch the dll
calls to __cxa_atexit and __cxa_finalize. */ structure of the DLL. Then use dll::handle == ImageBase as the actual DSO
handle value in calls to __cxa_atexit and __cxa_finalize.
Thus, __cxa_atexit becomes entirely independent of the incoming value of
dso_handle, as long as it's *some* pointer into the DSO's address space. */
extern "C" int extern "C" int
cygwin__cxa_atexit (void (*fn)(void *), void *obj, void *dso_handle) cygwin__cxa_atexit (void (*fn)(void *), void *obj, void *dso_handle)
{ {
if (dso_handle) dll *d = dso_handle ? dlls.find (dso_handle) : NULL;
dso_handle = *(void **) dso_handle; return __cxa_atexit (fn, obj, d ? d->handle : NULL);
return __cxa_atexit (fn, obj, dso_handle);
} }
/* This function is only called for applications built with Cygwin versions /* This function is only called for applications built with Cygwin versions