Usage of separate static function __DllMainCRTStartup() is needed for MSVC
stack cookie handling as written in documentation for C Runtime Error R6035:
https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/c-runtime-error-r6035
mingw-w64 does not support MSVC stack cookie handling, it was removed in
commit e6ac7e4230c9 ("crt: Remove the vestigial gs_support.c").
So merge static __DllMainCRTStartup() function directly into entry point
function DllMainCRTStartup().
---
mingw-w64-crt/crt/crtdll.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c
index 3d12d3f82c5f..797a8ab54e1d 100644
--- a/mingw-w64-crt/crt/crtdll.c
+++ b/mingw-w64-crt/crt/crtdll.c
@@ -160,29 +160,20 @@ i__leave:
return TRUE;
}
-static WINBOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID);
-
WINBOOL WINAPI DllMainCRTStartup (HANDLE, DWORD, LPVOID);
-__attribute__((used)) /* required due to GNU LD bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=30300 */
-WINBOOL WINAPI
-DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
-{
- __mingw_app_type = 0;
- return __DllMainCRTStartup (hDllHandle, dwReason, lpreserved);
-}
-
-static
#if defined(__i386__) || defined(_X86_)
/* We need to make sure that we align the stack to 16 bytes for the sake of SSE
opts in DllMain/DllEntryPoint or in functions called from
DllMain/DllEntryPoint. */
__attribute__((force_align_arg_pointer))
#endif
-__declspec(noinline) WINBOOL
-__DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
+__attribute__((used)) /* required due to GNU LD bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=30300 */
+WINBOOL WINAPI
+DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
WINBOOL retcode = TRUE;
+ __mingw_app_type = 0;
__native_dllmain_reason = dwReason;
if (dwReason == DLL_PROCESS_DETACH && __proc_attached <= 0)
{
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public