This simplifies mainCRTStartup() and WinMainCRTStartup() code.
We do not need to use __C_specific_handler dispatcher SEH handler because in
mainCRTStartup() and WinMainCRTStartup() functions was registered only one
filter function _gnu_exception_handler which applies for the whole function
scope (.l_start - .l_end). Same can be logic can be achieved by registering
the __mingw_SEH_error_handler SEH handler instead of __C_specific_handler
with _gnu_exception_handler.
__mingw_SEH_error_handler does not take or use any .seh_handlerdata.
---
mingw-w64-crt/crt/crtexe.c | 47 +++++++++-----------------------------
1 file changed, 11 insertions(+), 36 deletions(-)
diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
index 90304061ca78..105e9c20f54b 100644
--- a/mingw-w64-crt/crt/crtexe.c
+++ b/mingw-w64-crt/crt/crtexe.c
@@ -19,6 +19,11 @@
#if defined(__SEH__) && (!defined(__clang__) || __clang_major__ >= 7)
#define SEH_INLINE_ASM
+#ifdef __arm__
+#define ASM_EXCEPT "%%except"
+#else
+#define ASM_EXCEPT "@except"
+#endif
#endif
extern IMAGE_DOS_HEADER __ImageBase;
@@ -89,26 +94,11 @@ int WinMainCRTStartup (void)
.Handler = __mingw_SEH_error_handler,
};
__writefsdword (0, (DWORD)&exception_record); /* register SEH handler */
-#endif
- int ret = 255;
-#ifdef SEH_INLINE_ASM
- asm ("\t.l_startw:\n");
+#elif defined(SEH_INLINE_ASM)
+ asm volatile (".seh_handler %p0, " ASM_EXCEPT :: "i"
(__mingw_SEH_error_handler)); /* applies for the whole function */
#endif
__mingw_app_type = 1;
- ret = __tmainCRTStartup ();
-#ifdef SEH_INLINE_ASM
- asm ("\tnop\n"
- "\t.l_endw: nop\n"
-#ifdef __arm__
- "\t.seh_handler __C_specific_handler, %except\n"
-#else
- "\t.seh_handler __C_specific_handler, @except\n"
-#endif
- "\t.seh_handlerdata\n"
- "\t.long 1\n"
- "\t.rva .l_startw, .l_endw, _gnu_exception_handler ,.l_endw\n"
- "\t.text");
-#endif
+ int ret = __tmainCRTStartup ();
#if defined(__i386__)
__writefsdword (0, (DWORD)exception_record.Next); /* unregister SEH handler
*/
#endif
@@ -130,26 +120,11 @@ int mainCRTStartup (void)
.Handler = __mingw_SEH_error_handler,
};
__writefsdword (0, (DWORD)&exception_record); /* register SEH handler */
-#endif
- int ret = 255;
-#ifdef SEH_INLINE_ASM
- asm ("\t.l_start:\n");
+#elif defined(SEH_INLINE_ASM)
+ asm volatile (".seh_handler %p0, " ASM_EXCEPT :: "i"
(__mingw_SEH_error_handler)); /* applies for the whole function */
#endif
__mingw_app_type = 0;
- ret = __tmainCRTStartup ();
-#ifdef SEH_INLINE_ASM
- asm ("\tnop\n"
- "\t.l_end: nop\n"
-#ifdef __arm__
- "\t.seh_handler __C_specific_handler, %except\n"
-#else
- "\t.seh_handler __C_specific_handler, @except\n"
-#endif
- "\t.seh_handlerdata\n"
- "\t.long 1\n"
- "\t.rva .l_start, .l_end, _gnu_exception_handler ,.l_end\n"
- "\t.text");
-#endif
+ int ret = __tmainCRTStartup ();
#if defined(__i386__)
__writefsdword (0, (DWORD)exception_record.Next); /* unregister SEH handler
*/
#endif
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public