diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2014-11-06 15:32:21 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2014-11-06 15:32:21 +0000 |
commit | dfc361dad46347fea1089fff9ecd4dd3235703d3 (patch) | |
tree | ea145a53caebb8ab37f6b61520a1a008012f2af9 /winsup/cygwin/lib/atexit.c | |
parent | 97e2f27aa1c50d7ecb37314f912f7510d3ede879 (diff) | |
download | cygnal-dfc361dad46347fea1089fff9ecd4dd3235703d3.tar.gz cygnal-dfc361dad46347fea1089fff9ecd4dd3235703d3.tar.bz2 cygnal-dfc361dad46347fea1089fff9ecd4dd3235703d3.zip |
* dcrt0.cc (cygwin_atexit): Change preceeding comment to reflect
API version numbers.
* external.cc (cygwin_internal): disable setting cxx_malloc on 64 bit.
Add CW_FIXED_ATEXIT case.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* include/sys/cygwin.h (cygwin_getinfo_types): Add CW_FIXED_ATEXIT.
* lib/atexit.c (atexit): Test running Cygwin version by checking
return value of cygwin_internal (CW_FIXED_ATEXIT).
Diffstat (limited to 'winsup/cygwin/lib/atexit.c')
-rw-r--r-- | winsup/cygwin/lib/atexit.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/winsup/cygwin/lib/atexit.c b/winsup/cygwin/lib/atexit.c index af82d1de7..a2dec6267 100644 --- a/winsup/cygwin/lib/atexit.c +++ b/winsup/cygwin/lib/atexit.c @@ -9,11 +9,13 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ #include <stddef.h> +#include <sys/cygwin.h> #include <windows.h> /* Statically linked replacement for the former cygwin_atexit. We need the function here to be able to access the correct __dso_handle of the caller's DSO. */ + int atexit (void (*fn) (void)) { @@ -21,6 +23,7 @@ atexit (void (*fn) (void)) extern void *__dso_handle; extern void *__ImageBase; + void *fixed_dso_handle = &__dso_handle; /* Check for being called from inside the executable. If so, use NULL as __dso_handle. This allows to link executables with GCC versions not providing __dso_handle in crtbegin{S}.o. In this case our own @@ -28,7 +31,19 @@ atexit (void (*fn) (void)) __dso_handle always points to &__ImageBase, while the __dso_handle for executables provided by crtbegin.o usually points to NULL. That's what we remodel here. */ - return __cxa_atexit ((void (*)(void*))fn, NULL, - &__ImageBase == (void **) GetModuleHandleW (NULL) - ? NULL : &__dso_handle); + if (&__ImageBase == (void **) GetModuleHandleW (NULL)) + fixed_dso_handle = NULL; + /* With recent Cygwin versions starting with API version 0.280 we call + __cxa_atexit (which is actually the cygwin__cxa_atexit wrapper in + dcrt0.cc) with the address of __dso_handle since that's how g++ generates + calls to __cxa_atexit as well. However, when running an application + built with this atexit under an older Cygwin version, the __cxa_atexit + entry point is the one from newlib, which expects the *value* of + __dso_handle. So, check for the Cygwin version we're running under. + Older version prior to 0.280 don't know CW_FIXED_ATEXIT and return -1. + 0.280 and later return 0. */ + else if (cygwin_internal (CW_FIXED_ATEXIT) != 0) + fixed_dso_handle = __dso_handle; + + return __cxa_atexit ((void (*)(void*))fn, NULL, fixed_dso_handle); } |