From 3356605531e409d160a35da96d6243171aefdbe4 Mon Sep 17 00:00:00 2001 From: Trung Nguyen <57174311+trungnt2910@users.noreply.github.com> Date: Sun, 7 Jan 2024 04:33:33 +0000 Subject: [PATCH] third_party/libunwind: Fix unwind ABI `resumeParameters` in `_Unwind_FunctionContext` should be "unwind words" (typically 64-bit) instead of 32-bit. This fix, along with the pending libcxxabi port, allows the first binaries with exception handling to properly run. --- third_party/libunwind/README.cosmo | 3 +++ third_party/libunwind/Unwind-sjlj.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/third_party/libunwind/README.cosmo b/third_party/libunwind/README.cosmo index 3524d2a39..e74e838c3 100644 --- a/third_party/libunwind/README.cosmo +++ b/third_party/libunwind/README.cosmo @@ -11,3 +11,6 @@ ORIGIN Author: Tobias Hieta Date: Tue, 28 Nov 2023 09:52:28 +0100 +LOCAL CHANGES + - Fixed `_Unwind_FunctionContext` struct to be ABI-compatible with code + generated by GCC. diff --git a/third_party/libunwind/Unwind-sjlj.c b/third_party/libunwind/Unwind-sjlj.c index ae8b73351..514358e5b 100644 --- a/third_party/libunwind/Unwind-sjlj.c +++ b/third_party/libunwind/Unwind-sjlj.c @@ -28,6 +28,8 @@ #if defined(_LIBUNWIND_BUILD_SJLJ_APIS) +typedef uintptr_t _Unwind_Word __attribute__((__mode__(__unwind_word__))); + struct _Unwind_FunctionContext { // next function in stack of handlers struct _Unwind_FunctionContext *prev; @@ -47,7 +49,7 @@ struct _Unwind_FunctionContext { uint32_t resumeLocation; // set by personality handler to be parameters passed to landing pad function - uint32_t resumeParameters[4]; + _Unwind_Word resumeParameters[4]; #endif // set by calling function before registering