diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-08-13 07:35:50 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-08-13 07:35:50 +0000 |
commit | ce5eb135a299c36b9c929351b967de793809f895 (patch) | |
tree | 7309c3833cd20103715b93163be19ebce5abf14d /winsup/cygwin/dlfcn.cc | |
parent | 61189f19de6175e82cdb43c2ff5ed50f953ba3fa (diff) | |
download | cygnal-ce5eb135a299c36b9c929351b967de793809f895.tar.gz cygnal-ce5eb135a299c36b9c929351b967de793809f895.tar.bz2 cygnal-ce5eb135a299c36b9c929351b967de793809f895.zip |
* cxx.cc (default_cygwin_cxx_malloc): Enhance commenting.
* dll_init.cc (dll_dllcrt0_1): Likewise.
* dlfcn.cc (dlopen): Prevent dlopen()'d DLL from installing any
cxx malloc overrides.
* include/cygwin/cygwin_dll.h (__dynamically_loaded): New variable.
* lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Check it and only
install cxx malloc overrides when statically loaded. Extend comments.
Diffstat (limited to 'winsup/cygwin/dlfcn.cc')
-rw-r--r-- | winsup/cygwin/dlfcn.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc index a9e3295da..bc95e221c 100644 --- a/winsup/cygwin/dlfcn.cc +++ b/winsup/cygwin/dlfcn.cc @@ -93,7 +93,28 @@ dlopen (const char *name, int) wchar_t *path = tp.w_get (); pc.get_wide_win32_path (path); + + /* Workaround for broken DLLs built against Cygwin versions 1.7.0-49 + up to 1.7.0-57. They override the cxx_malloc pointer in their + DLL initialization code even if loaded dynamically. This is a + no-no since a later dlclose lets cxx_malloc point into nirvana. + The below kludge "fixes" that by reverting the original cxx_malloc + pointer after LoadLibrary. This implies that their overrides + won't be applied; that's OK. All overrides should be present at + final link time, as Windows doesn't allow undefined references; + it would actually be wrong for a dlopen'd DLL to opportunistically + override functions in a way that wasn't known then. We're not + going to try and reproduce the full ELF dynamic loader here! */ + + /* Store original cxx_malloc pointer. */ + struct per_process_cxx_malloc *tmp_malloc; + tmp_malloc = __cygwin_user_data.cxx_malloc; + ret = (void *) LoadLibraryW (path); + + /* Restore original cxx_malloc pointer. */ + __cygwin_user_data.cxx_malloc = tmp_malloc; + if (ret == NULL) __seterrno (); } |