在 2025-4-24 20:10, Martin Storsjö 写道:
On Thu, 24 Apr 2025, Jacek Caban wrote:I think this is fine. But don't we have something similar in mingw-w64-crt too? (There we only seem to have a "return" statement after the SEH inline assembly block though.)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.
I have an alternative implementation that doesn't use handler data and does not
require switching sections.
```
// in main function:
__asm__ (".seh_handler _top_se_handler, @except");
static __attribute__((__used__))
EXCEPTION_DISPOSITION
__cdecl
_top_se_handler(EXCEPTION_RECORD* pExceptionRecord, void* pEstablisherFrame,
CONTEXT* pContextRecord, void* pDispatcherContext)
{
(void) pEstablisherFrame;
(void) pContextRecord;
(void) pDispatcherContext;
// `throw` raises an exception with code `(1 << 29) | 'GCC'`. If control
// flow resumes after it, `std::terminate()` is called.
if((pExceptionRecord->ExceptionCode & 0x20FFFFFFU) != 0x20474343U)
return ExceptionContinueSearch;
if(pExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE)
return ExceptionContinueSearch;
return ExceptionContinueExecution;
}
```
--
Best regards,
LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
