crt: Fix .seh_handler directives for ARM

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] 6b75a3523f
[2] https://sourceware.org/binutils/docs/as/Section.html#Section

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö 2022-05-07 00:13:12 +03:00
parent c90a062674
commit 08fd589f44
2 changed files with 12 additions and 0 deletions

View File

@ -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"

View File

@ -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"