The latest LLVM from git supports generating SEH unwind info on ARM.

In ARM assembly, '@' is a comment character. Therefore, the use
of that character in .seh_handler directives doesn't work on ARM.

LLVM now accepts '%' as an alternative for '@' in .seh_handler
directives [1], consistent with how GAS explains using '%' as an
alternative for '@' in such cases [2]. (However, GAS doesn't
support '%' as alternative char in .seh_handler on x86_64, not
yet at least.)

[1] 
https://github.com/llvm/llvm-project/commit/6b75a3523ffd79bc03265469aeeedab26079026e
[2] https://sourceware.org/binutils/docs/as/Section.html#Section

Signed-off-by: Martin Storsjö <[email protected]>
---
 mingw-w64-crt/crt/crtexe.c                   | 8 ++++++++
 mingw-w64-libraries/winpthreads/src/thread.c | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
index c6d43168b..65303f818 100644
--- a/mingw-w64-crt/crt/crtexe.c
+++ b/mingw-w64-crt/crt/crtexe.c
@@ -177,7 +177,11 @@ int WinMainCRTStartup (void)
 #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"
@@ -203,7 +207,11 @@ int mainCRTStartup (void)
 #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"
diff --git a/mingw-w64-libraries/winpthreads/src/thread.c 
b/mingw-w64-libraries/winpthreads/src/thread.c
index 62d0f4b56..f7aba360e 100644
--- a/mingw-w64-libraries/winpthreads/src/thread.c
+++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -1527,7 +1527,11 @@ pthread_create_wrapper (void *args)
         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"
-- 
2.25.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to