On Wednesday 04 February 2026 13:00:20 LIU Hao wrote:
> 在 2026-2-4 07:38, Jacek Caban 写道:
> > On 12/26/25 14:05, Pali Rohár wrote:
> > > > So the safest solution is, still, to hard-code the handler name in
> > > > assembly string.
> > > That is truth. I wanted to avoid hardcoding symbol names to prevent
> > > possible symbol mangling issues, and the %p or %c modifier looked like
> > > something which is prepared for those cases like this one.
> >
> > FWIW, on ARM64EC the compiler cannot know whether you mean the mangled
> > or demangled symbol; both are valid names referring to the same thing,
> > but with different meanings. In this case, you want the mangled form
> > ("#__mingw_SEH_error_handler"). The demangled form will often work, but
> > it is less reliable (archive symbol tables do not include it, so it
> > relies on the alias being defined one way or another).
>
> One possible workaround for that is to define an ARM64EC thunk with internal
> linkage for the handler, and to use the thunk as the handler which will not
> have a mangled name:
>
> static EXCEPTION_DISPOSITION
> __cdecl
> do_mingw_SEH_error_handler(EXCEPTION_RECORD* ExceptionRecord,
> void* EstablisherFrame, CONTEXT* ContextRecord,
> void* DispatcherContext)
> {
> return __mingw_SEH_error_handler(ExceptionRecord, EstablisherFrame,
> ContextRecord, DispatcherContext);
> }
>
> // ...
> __asm__ (".seh_handler %c0, " ASM_EXCEPT :: "i"
> (do_mingw_SEH_error_handler));
>
What is the difference between do_mingw_SEH_error_handler and
__mingw_SEH_error_handler?
Should not be both functions of same type and with same ABI? I quite do
not understand why the local static function will work but the extern
function would not.
Or is the reason that the extern function should be mangled with
leading # character (as Jacek wrote in the above message) and static
local function do not have to?
Sorry if this is a stupid question, but I somehow have not caught this
topic and now I'm not sure about the formal syntax of GNU assembler
.seh_handler directive.
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public