[libunwind] Fix SEH unwinding on ARM

Check `__SEH__` when checking if ARM EHABI should be implied,
similarly to 4a3722a2c3 / D126866.

Fix a warning by using the right format specifier (PRIxPTR instead
of PRIx64), and add a double->float cast in a codepath that hasn't
been built so far.

This is enough to make SEH unwinding of itanium ABI exceptions on
ARM mostly work - one specific issue is fixed in a separate follow-up
patch.

Differential Revision: https://reviews.llvm.org/D126867
This commit is contained in:
Martin Storsjö 2022-05-07 00:26:45 +03:00
parent 03c19f41a2
commit 7c0e93cb89
4 changed files with 5 additions and 5 deletions

View File

@ -12,7 +12,7 @@
#define _LIBUNWIND_VERSION 15000 #define _LIBUNWIND_VERSION 15000
#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
!defined(__ARM_DWARF_EH__) !defined(__ARM_DWARF_EH__) && !defined(__SEH__)
#define _LIBUNWIND_ARM_EHABI #define _LIBUNWIND_ARM_EHABI
#endif #endif

View File

@ -81,7 +81,7 @@ typedef struct unw_addr_space *unw_addr_space_t;
typedef int unw_regnum_t; typedef int unw_regnum_t;
typedef uintptr_t unw_word_t; typedef uintptr_t unw_word_t;
#if defined(__arm__) && !defined(__ARM_DWARF_EH__) #if defined(__arm__) && !defined(__ARM_DWARF_EH__) && !defined(__SEH__)
typedef uint64_t unw_fpreg_t; typedef uint64_t unw_fpreg_t;
#else #else
typedef double unw_fpreg_t; typedef double unw_fpreg_t;

View File

@ -255,8 +255,8 @@ unwind_phase2_forced(unw_context_t *uc,
(frameInfo.start_ip + offset > frameInfo.end_ip)) (frameInfo.start_ip + offset > frameInfo.end_ip))
functionName = ".anonymous."; functionName = ".anonymous.";
_LIBUNWIND_TRACE_UNWINDING( _LIBUNWIND_TRACE_UNWINDING(
"unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIx64 "unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIxPTR
", func=%s, lsda=0x%" PRIx64 ", personality=0x%" PRIx64, ", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR,
(void *)exception_object, frameInfo.start_ip, functionName, (void *)exception_object, frameInfo.start_ip, functionName,
frameInfo.lsda, frameInfo.handler); frameInfo.lsda, frameInfo.handler);
} }

View File

@ -863,7 +863,7 @@ void UnwindCursor<A, R>::setFloatReg(int regNum, unw_fpreg_t value) {
uint32_t w; uint32_t w;
float f; float f;
} d; } d;
d.f = value; d.f = (float)value;
_msContext.S[regNum - UNW_ARM_S0] = d.w; _msContext.S[regNum - UNW_ARM_S0] = d.w;
} }
if (regNum >= UNW_ARM_D0 && regNum <= UNW_ARM_D31) { if (regNum >= UNW_ARM_D0 && regNum <= UNW_ARM_D31) {