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

Corinna Vinschen corinna@sourceware.org
Mon Mar 30 08:32:20 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0cde89e5e6b3cd00592b36d61c5308eb03c84ece

commit 0cde89e5e6b3cd00592b36d61c5308eb03c84ece
Author:     Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
AuthorDate: Tue Mar 24 17:50:01 2026 +0530
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Mon Mar 30 10:20:49 2026 +0200

    Cygwin: Add ARM64 support for SEH handler symbol references
    
    Introduces conditional symbol references for structured exception handling
    to support ARM64 architecture. Ensures correct handler symbol names are
    used based on the target platform.
    
    Signed-off-by: Evgeny Karpov <Evgeny.Karpov@microsoft.com>
    Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.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_includes/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));
 };
 
+#if defined (__aarch64__)
+#define EXCEPTION_MYFAULT_REF "_ZN9exception7myfaultEP17_EXCEPTION_RECORDPvP8_CONTEXTP25_DISPATCHER_CONTEXT_ARM64"
+#else
+#define EXCEPTION_MYFAULT_REF "_ZN9exception7myfaultEP17_EXCEPTION_RECORDPvP8_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_CONTEXTP19_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
 
 #define exception_list void
-typedef struct _DISPATCHER_CONTEXT *PDISPATCHER_CONTEXT;
+
+#if defined (__aarch64__)
+#define EXCEPTION_HANDLE_REF "_ZN9exception6handleEP17_EXCEPTION_RECORDPvP8_CONTEXTP25_DISPATCHER_CONTEXT_ARM64"
+ #else
+#define EXCEPTION_HANDLE_REF "_ZN9exception6handleEP17_EXCEPTION_RECORDPvP8_CONTEXTP19_DISPATCHER_CONTEXT"
+#endif
 
 class exception
 {
@@ -21,8 +26,8 @@ public:
     /* Install SEH handler. */
     asm volatile ("\n\
     1:									\n\
-      .seh_handler							  \
-	_ZN9exception6handleEP17_EXCEPTION_RECORDPvP8_CONTEXTP19_DISPATCHER_CONTEXT,	  \
+      .seh_handler "							  \
+	EXCEPTION_HANDLE_REF ",	  \
 	@except								\n\
       .seh_handlerdata							\n\
       .long 1								\n\


More information about the Cygwin-cvs mailing list