On Wed, 27 Nov 2024, Pali Rohár wrote:

i386 DLL builds have same issue as EXE builds, entry point (DllMain or
DllEntryPoint) can use SSE and therefore stack should be aligned to
16-bytes. Use attribute force_align_arg_pointer for __DllMainCRTStartup,
like it is already for __tmainCRTStartup. Also mark it as static.

This code was copied from crtexe.c __tmainCRTStartup() function.
---
mingw-w64-crt/crt/crtdll.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c
index f59d7326236a..754648a6382b 100644
--- a/mingw-w64-crt/crt/crtdll.c
+++ b/mingw-w64-crt/crt/crtdll.c
@@ -150,6 +150,12 @@ DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, 
LPVOID lpreserved)
  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 DllMain/DllEntryPoint. 
 */

This feels like a typo - I presume it should say "in DllMain/DllEntryPoint or in functions called _by_ DllMain/DllEntryPoint"? I see that the existing case in crtexe.c has a similar typo.

The change itself seems ok to me.

// Martin

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to