winpthreads: Move SEH handler declaration to end of function
This avoids splitting the function into multiple .text chunks, which triggers an error on ARM64EC:
error: cannot perform a PC-relative fixup with a non-zero symbol offset
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
diff --git a/mingw-w64-libraries/winpthreads/src/thread.c b/mingw-w64-libraries/winpthreads/src/thread.c
index 742a022..2ebf1ad 100644
--- a/mingw-w64-libraries/winpthreads/src/thread.c
+++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -1553,17 +1553,7 @@
if (tv->func)
trslt = (intptr_t) tv->func(tv->ret_arg);
#ifdef __SEH__
- asm ("\tnop\n\t.tl_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 .tl_start, .tl_end, _gnu_exception_handler ,.tl_end\n"
- "\t.text"
- );
+ asm ("\tnop\n\t.tl_end: nop\n");
#endif
pthread_mutex_lock (&mtx_pthr_locked);
tv->ret_arg = (void*) trslt;
@@ -1601,6 +1591,19 @@
Sleep (0);
_endthreadex (rslt);
return rslt;
+
+#if defined(__SEH__)
+ asm(
+#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 .tl_start, .tl_end, _gnu_exception_handler ,.tl_end\n"
+ "\t.text\n");
+#endif
}
int