[libunwind] f5b997e - [Unwind] Harmonise exception class for EHABI spec.

Daniel Kiss via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 2 02:31:07 PDT 2021


Author: Daniel Kiss
Date: 2021-09-02T11:31:03+02:00
New Revision: f5b997e6b7061323fff13fafcc0c311d9e78e848

URL: https://github.com/llvm/llvm-project/commit/f5b997e6b7061323fff13fafcc0c311d9e78e848
DIFF: https://github.com/llvm/llvm-project/commit/f5b997e6b7061323fff13fafcc0c311d9e78e848.diff

LOG: [Unwind] Harmonise exception class for EHABI spec.

EHABI defines the exception class as char[8] instead of uint64_t [1].
For ABI compatibility the ABI the definition needs to be updated.

[1] https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst#82language-independent-unwinding-types-and-functions

Reviewed By: manojgupta, MaskRay, #libunwind

Differential Revision: https://reviews.llvm.org/D109047

Added: 
    

Modified: 
    libcxxabi/test/forced_unwind1.pass.cpp
    libcxxabi/test/forced_unwind2.pass.cpp
    libunwind/include/unwind.h
    libunwind/include/unwind_arm_ehabi.h
    libunwind/include/unwind_itanium.h
    libunwind/src/UnwindLevel1-gcc-ext.c
    libunwind/test/forceunwind.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxxabi/test/forced_unwind1.pass.cpp b/libcxxabi/test/forced_unwind1.pass.cpp
index b6963a0242996..de376a8ad94f0 100644
--- a/libcxxabi/test/forced_unwind1.pass.cpp
+++ b/libcxxabi/test/forced_unwind1.pass.cpp
@@ -53,7 +53,7 @@ static void cleanup(_Unwind_Reason_Code, struct _Unwind_Exception* exc) {
 
 static void forced_unwind() {
   _Unwind_Exception* exc = new _Unwind_Exception;
-  exc->exception_class = 0;
+  memset(&exc->exception_class, 0, sizeof(exc->exception_class));
   exc->exception_cleanup = cleanup;
   _Unwind_ForcedUnwind(exc, Stop<_Unwind_Stop_Fn>::stop, 0);
   abort();

diff  --git a/libcxxabi/test/forced_unwind2.pass.cpp b/libcxxabi/test/forced_unwind2.pass.cpp
index 037f0499282f6..a221dfc2e282b 100644
--- a/libcxxabi/test/forced_unwind2.pass.cpp
+++ b/libcxxabi/test/forced_unwind2.pass.cpp
@@ -41,7 +41,7 @@ struct Stop<R (*)(Args...)> {
 
 static void forced_unwind() {
   _Unwind_Exception* exc = new _Unwind_Exception;
-  exc->exception_class = 0;
+  memset(&exc->exception_class, 0, sizeof(exc->exception_class));
   exc->exception_cleanup = 0;
   _Unwind_ForcedUnwind(exc, Stop<_Unwind_Stop_Fn>::stop, 0);
   abort();

diff  --git a/libunwind/include/unwind.h b/libunwind/include/unwind.h
index 87c3cf6c804ec..2101401337082 100644
--- a/libunwind/include/unwind.h
+++ b/libunwind/include/unwind.h
@@ -64,7 +64,7 @@ typedef struct _Unwind_Context _Unwind_Context;   // opaque
 typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
     (int version,
      _Unwind_Action actions,
-     uint64_t exceptionClass,
+     _Unwind_Exception_Class exceptionClass,
      _Unwind_Exception* exceptionObject,
      struct _Unwind_Context* context,
      void* stop_parameter);

diff  --git a/libunwind/include/unwind_arm_ehabi.h b/libunwind/include/unwind_arm_ehabi.h
index 5ad0887225605..747129af5e7e7 100644
--- a/libunwind/include/unwind_arm_ehabi.h
+++ b/libunwind/include/unwind_arm_ehabi.h
@@ -27,9 +27,10 @@ typedef uint32_t _Unwind_EHT_Header;
 struct _Unwind_Control_Block;
 typedef struct _Unwind_Control_Block _Unwind_Control_Block;
 #define _Unwind_Exception _Unwind_Control_Block /* Alias */
+typedef uint8_t _Unwind_Exception_Class[8];
 
 struct _Unwind_Control_Block {
-  uint64_t exception_class;
+  _Unwind_Exception_Class exception_class;
   void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block*);
 
   /* Unwinder cache, private fields for the unwinder's use */

diff  --git a/libunwind/include/unwind_itanium.h b/libunwind/include/unwind_itanium.h
index eeb45f6228323..794e990dc076d 100644
--- a/libunwind/include/unwind_itanium.h
+++ b/libunwind/include/unwind_itanium.h
@@ -16,9 +16,10 @@
 struct _Unwind_Context;   // opaque
 struct _Unwind_Exception; // forward declaration
 typedef struct _Unwind_Exception _Unwind_Exception;
+typedef uint64_t _Unwind_Exception_Class;
 
 struct _Unwind_Exception {
-  uint64_t exception_class;
+  _Unwind_Exception_Class exception_class;
   void (*exception_cleanup)(_Unwind_Reason_Code reason,
                             _Unwind_Exception *exc);
 #if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)

diff  --git a/libunwind/src/UnwindLevel1-gcc-ext.c b/libunwind/src/UnwindLevel1-gcc-ext.c
index d69267ba25fe6..c3fa8b6655713 100644
--- a/libunwind/src/UnwindLevel1-gcc-ext.c
+++ b/libunwind/src/UnwindLevel1-gcc-ext.c
@@ -109,7 +109,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
   // Create a mock exception object for force unwinding.
   _Unwind_Exception ex;
   memset(&ex, '\0', sizeof(ex));
-  ex.exception_class = 0x434C4E47554E5700; // CLNGUNW\0
+  strcpy(&ex.exception_class, "CLNGUNW");
 #endif
 
   // walk each frame

diff  --git a/libunwind/test/forceunwind.pass.cpp b/libunwind/test/forceunwind.pass.cpp
index e74aa3faa0803..466697264035b 100644
--- a/libunwind/test/forceunwind.pass.cpp
+++ b/libunwind/test/forceunwind.pass.cpp
@@ -27,7 +27,7 @@ void foo();
 _Unwind_Exception ex;
 
 _Unwind_Reason_Code stop(int version, _Unwind_Action actions,
-                         uint64_t exceptionClass,
+                         _Unwind_Exception_Class exceptionClass,
                          _Unwind_Exception *exceptionObject,
                          struct _Unwind_Context *context,
                          void *stop_parameter) {
@@ -57,7 +57,7 @@ __attribute__((noinline)) void foo() {
 #if defined(_LIBUNWIND_ARM_EHABI)
   // Create a mock exception object.
   memset(e, '\0', sizeof(*e));
-  e->exception_class = 0x434C4E47554E5700; // CLNGUNW\0
+  strcpy(reinterpret_cast<char *>(&e->exception_class), "CLNGUNW");
 #endif
   _Unwind_ForcedUnwind(e, stop, (void *)&foo);
 }


        


More information about the cfe-commits mailing list