Skip to content

Commit b93344e

Browse files
DanielKristofKissmemfrob
authored andcommitted
[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
1 parent c9754b7 commit b93344e

File tree

7 files changed

+10
-8
lines changed

7 files changed

+10
-8
lines changed

libcxxabi/test/forced_unwind1.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void cleanup(_Unwind_Reason_Code, struct _Unwind_Exception* exc) {
5353

5454
static void forced_unwind() {
5555
_Unwind_Exception* exc = new _Unwind_Exception;
56-
exc->exception_class = 0;
56+
memset(&exc->exception_class, 0, sizeof(exc->exception_class));
5757
exc->exception_cleanup = cleanup;
5858
_Unwind_ForcedUnwind(exc, Stop<_Unwind_Stop_Fn>::stop, 0);
5959
abort();

libcxxabi/test/forced_unwind2.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct Stop<R (*)(Args...)> {
4141

4242
static void forced_unwind() {
4343
_Unwind_Exception* exc = new _Unwind_Exception;
44-
exc->exception_class = 0;
44+
memset(&exc->exception_class, 0, sizeof(exc->exception_class));
4545
exc->exception_cleanup = 0;
4646
_Unwind_ForcedUnwind(exc, Stop<_Unwind_Stop_Fn>::stop, 0);
4747
abort();

libunwind/include/unwind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ typedef struct _Unwind_Context _Unwind_Context; // opaque
6464
typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
6565
(int version,
6666
_Unwind_Action actions,
67-
uint64_t exceptionClass,
67+
_Unwind_Exception_Class exceptionClass,
6868
_Unwind_Exception* exceptionObject,
6969
struct _Unwind_Context* context,
7070
void* stop_parameter);

libunwind/include/unwind_arm_ehabi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ typedef uint32_t _Unwind_EHT_Header;
2727
struct _Unwind_Control_Block;
2828
typedef struct _Unwind_Control_Block _Unwind_Control_Block;
2929
#define _Unwind_Exception _Unwind_Control_Block /* Alias */
30+
typedef uint8_t _Unwind_Exception_Class[8];
3031

3132
struct _Unwind_Control_Block {
32-
uint64_t exception_class;
33+
_Unwind_Exception_Class exception_class;
3334
void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block*);
3435

3536
/* Unwinder cache, private fields for the unwinder's use */

libunwind/include/unwind_itanium.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
struct _Unwind_Context; // opaque
1717
struct _Unwind_Exception; // forward declaration
1818
typedef struct _Unwind_Exception _Unwind_Exception;
19+
typedef uint64_t _Unwind_Exception_Class;
1920

2021
struct _Unwind_Exception {
21-
uint64_t exception_class;
22+
_Unwind_Exception_Class exception_class;
2223
void (*exception_cleanup)(_Unwind_Reason_Code reason,
2324
_Unwind_Exception *exc);
2425
#if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)

libunwind/src/UnwindLevel1-gcc-ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
109109
// Create a mock exception object for force unwinding.
110110
_Unwind_Exception ex;
111111
memset(&ex, '\0', sizeof(ex));
112-
ex.exception_class = 0x434C4E47554E5700; // CLNGUNW\0
112+
strcpy(&ex.exception_class, "CLNGUNW");
113113
#endif
114114

115115
// walk each frame

libunwind/test/forceunwind.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void foo();
2727
_Unwind_Exception ex;
2828

2929
_Unwind_Reason_Code stop(int version, _Unwind_Action actions,
30-
uint64_t exceptionClass,
30+
_Unwind_Exception_Class exceptionClass,
3131
_Unwind_Exception *exceptionObject,
3232
struct _Unwind_Context *context,
3333
void *stop_parameter) {
@@ -57,7 +57,7 @@ __attribute__((noinline)) void foo() {
5757
#if defined(_LIBUNWIND_ARM_EHABI)
5858
// Create a mock exception object.
5959
memset(e, '\0', sizeof(*e));
60-
e->exception_class = 0x434C4E47554E5700; // CLNGUNW\0
60+
strcpy(reinterpret_cast<char *>(&e->exception_class), "CLNGUNW");
6161
#endif
6262
_Unwind_ForcedUnwind(e, stop, (void *)&foo);
6363
}

0 commit comments

Comments
 (0)