[newlib-cygwin/main] Cygwin: Add ARM64 support for SEH handler symbol references

Corinna Vinschen via Cygwin-cvs <[email protected]> Mon, 30 Mar 2026 08:32:20 +0000 (GMT)
Newsgroups gmane.os.cygwin.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D0cde89e5e6b=
3cd00592b36d61c5308eb03c84ece

commit 0cde89e5e6b3cd00592b36d61c5308eb03c84ece
Author:     Thirumalai Nagalingam <[email protected]=
om>
AuthorDate: Tue Mar 24 17:50:01 2026 +0530
Commit:     Corinna Vinschen <[email protected]>
CommitDate: Mon Mar 30 10:20:49 2026 +0200

    Cygwin: Add ARM64 support for SEH handler symbol references
   =20
    Introduces conditional symbol references for structured exception handl=
ing
    to support ARM64 architecture. Ensures correct handler symbol names are
    used based on the target platform.
   =20
    Signed-off-by: Evgeny Karpov <[email protected]>
    Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewa=
reinc.com>

Diff:
---
 winsup/cygwin/local_includes/cygtls.h    |  8 +++++++-
 winsup/cygwin/local_includes/exception.h | 11 ++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/winsup/cygwin/local_includes/cygtls.h b/winsup/cygwin/local_in=
cludes/cygtls.h
index 9f83c134c88c..336c72a066d5 100644
--- a/winsup/cygwin/local_includes/cygtls.h
+++ b/winsup/cygwin/local_includes/cygtls.h
@@ -344,6 +344,12 @@ public:
   void leave () __attribute__ ((returns_twice));
 };
=20
+#if defined (__aarch64__)
+#define EXCEPTION_MYFAULT_REF "_ZN9exception7myfaultEP17_EXCEPTION_RECORDP=
vP8_CONTEXTP25_DISPATCHER_CONTEXT_ARM64"
+#else
+#define EXCEPTION_MYFAULT_REF "_ZN9exception7myfaultEP17_EXCEPTION_RECORDP=
vP8_CONTEXTP19_DISPATCHER_CONTEXT"
+#endif
+
 /* Exception handling macros. This is a handmade SEH try/except. */
 #define __mem_barrier	__asm__ __volatile__ ("" ::: "memory")
 #define __try \
@@ -352,7 +358,7 @@ public:
     __mem_barrier; \
     san __sebastian (&&__l_except); \
     __asm__ goto ("\n" \
-      "  .seh_handler _ZN9exception7myfaultEP17_EXCEPTION_RECORDPvP8_CONTE=
XTP19_DISPATCHER_CONTEXT, @except						\n" \
+      "  .seh_handler " EXCEPTION_MYFAULT_REF ", @except						\n" \
       "  .seh_handlerdata						\n" \
       "  .long 1							\n" \
       "  .rva %l[__l_try],%l[__l_endtry],%l[__l_except],%l[__l_except]	\n"=
 \
diff --git a/winsup/cygwin/local_includes/exception.h b/winsup/cygwin/local=
_includes/exception.h
index 13159d17b0bc..19bb109de65a 100644
--- a/winsup/cygwin/local_includes/exception.h
+++ b/winsup/cygwin/local_includes/exception.h
@@ -7,7 +7,12 @@ details. */
 #pragma once
=20
 #define exception_list void
-typedef struct _DISPATCHER_CONTEXT *PDISPATCHER_CONTEXT;
+
+#if defined (__aarch64__)
+#define EXCEPTION_HANDLE_REF "_ZN9exception6handleEP17_EXCEPTION_RECORDPvP=
8_CONTEXTP25_DISPATCHER_CONTEXT_ARM64"
+ #else
+#define EXCEPTION_HANDLE_REF "_ZN9exception6handleEP17_EXCEPTION_RECORDPvP=
8_CONTEXTP19_DISPATCHER_CONTEXT"
+#endif
=20
 class exception
 {
@@ -21,8 +26,8 @@ public:
     /* Install SEH handler. */
     asm volatile ("\n\
     1:									\n\
-      .seh_handler							  \
-	_ZN9exception6handleEP17_EXCEPTION_RECORDPvP8_CONTEXTP19_DISPATCHER_CONTE=
XT,	  \
+      .seh_handler "							  \
+	EXCEPTION_HANDLE_REF ",	  \
 	@except								\n\
       .seh_handlerdata							\n\
       .long 1								\n\