[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
This commit is contained in:
Daniel Kiss 2021-09-02 11:30:26 +02:00
parent 9621bbdf62
commit f5b997e6b7
7 changed files with 10 additions and 8 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -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 */

View File

@ -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__)

View File

@ -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

View File

@ -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);
}