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
---
I haven't looked deeper into the LLVM side. Even if there's something that
could be improved there, splitting a function like this feels like asking for
trouble, so the patch seems like an improvement regardless.

 mingw-w64-libraries/winpthreads/src/thread.c | 25 +++++++++++---------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/mingw-w64-libraries/winpthreads/src/thread.c 
b/mingw-w64-libraries/winpthreads/src/thread.c
index 742a02238..2ebf1ad66 100644
--- a/mingw-w64-libraries/winpthreads/src/thread.c
+++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -1553,17 +1553,7 @@ pthread_create_wrapper (void *args)
       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 @@ pthread_create_wrapper (void *args)
    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
-- 
2.49.0



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

Reply via email to