[PATCH 1/1] Cygwin: Fix SEH and signal handling on AArch64

Evgeny Karpov evgeny.karpov@arm.com
Tue Mar 31 16:49:27 GMT 2026


On Mon, Mar 30, 2026, Corinna Vinschen wrote:
> On Mar 27 12:43, Igor Podgainoi wrote:
> > This patch adds the SEH_CODE macro (defined in exception.h), allowing
> > a single EXCEPTION_HANDLER_DATA metadata definition to be used on both
> > AArch64 and x86_64 architectures.
> >
> > It also fixes an issue related to stack replacement in _dll_crt0 that
> > impacts SEH and signal handling, where due to an epilogue optimization
> > on AArch64 the epilogue might appear before _main_tls->call. However,
> > after the stack replacement this optimization becomes broken.
>
> Can you explain why this problem only affects aarch64 and not x86_64
> as well?

It looks like the x86_64 epilogue is also optimized and appears before
_main_tls->call.
However, the x86_64 epilogue uses the shadow stack which was allocated after
the stack replacement. It means if _dll_crt0 is modified, it might bring more
operations for unwinding, and that might access the stack outside of the shadow
space. It will lead to the same issue as on AArch64. Potentially, the compiler
barrier should be enabled also on x86_64. And the shadow space concept does not
apply to AArch64.

Regards,
Evgeny

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the Cygwin-patches mailing list