For EXE builds __mingw_init_ehandler() function is called after the
_pei386_runtime_relocator() from the __tmainCRTStartup() (and not from the
WinMainCRTStartup() function).

Do same for DLL builds and call __mingw_init_ehandler() from
__DllMainCRTStartup() instead of DllMainCRTStartup().
---
 mingw-w64-crt/crt/crtdll.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c
index d08d2a81f0dd..f59d7326236a 100644
--- a/mingw-w64-crt/crt/crtdll.c
+++ b/mingw-w64-crt/crt/crtdll.c
@@ -147,12 +147,6 @@ WINBOOL WINAPI
 DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
 {
   __mingw_app_type = 0;
-  if (dwReason == DLL_PROCESS_ATTACH)
-    {
-#if defined(__x86_64__) && !defined(__SEH__)
-      __mingw_init_ehandler ();
-#endif
-    }
   return __DllMainCRTStartup (hDllHandle, dwReason, lpreserved);
 }
 
@@ -168,6 +162,12 @@ __DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, 
LPVOID lpreserved)
        goto i__leave;
     }
   _pei386_runtime_relocator ();
+
+#if defined(__x86_64__) && !defined(__SEH__)
+  if (dwReason == DLL_PROCESS_ATTACH)
+    __mingw_init_ehandler ();
+#endif
+
   if (dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH)
     {
         retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved);
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to