Skip to content

Commit

Permalink
[libunwind] Fix SEH unwinding on ARM
Browse files Browse the repository at this point in the history
Check `__SEH__` when checking if ARM EHABI should be implied,
similarly to 4a3722a / 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
  • Loading branch information
mstorsjo committed Jun 6, 2022
1 parent 03c19f4 commit 7c0e93c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libunwind/include/__libunwind_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#define _LIBUNWIND_VERSION 15000

#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
!defined(__ARM_DWARF_EH__)
!defined(__ARM_DWARF_EH__) && !defined(__SEH__)
#define _LIBUNWIND_ARM_EHABI
#endif

Expand Down
2 changes: 1 addition & 1 deletion libunwind/include/libunwind.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ typedef struct unw_addr_space *unw_addr_space_t;

typedef int unw_regnum_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;
#else
typedef double unw_fpreg_t;
Expand Down
4 changes: 2 additions & 2 deletions libunwind/src/Unwind-seh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ unwind_phase2_forced(unw_context_t *uc,
(frameInfo.start_ip + offset > frameInfo.end_ip))
functionName = ".anonymous.";
_LIBUNWIND_TRACE_UNWINDING(
"unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIx64
", func=%s, lsda=0x%" PRIx64 ", personality=0x%" PRIx64,
"unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIxPTR
", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR,
(void *)exception_object, frameInfo.start_ip, functionName,
frameInfo.lsda, frameInfo.handler);
}
Expand Down
2 changes: 1 addition & 1 deletion libunwind/src/UnwindCursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ void UnwindCursor<A, R>::setFloatReg(int regNum, unw_fpreg_t value) {
uint32_t w;
float f;
} d;
d.f = value;
d.f = (float)value;
_msContext.S[regNum - UNW_ARM_S0] = d.w;
}
if (regNum >= UNW_ARM_D0 && regNum <= UNW_ARM_D31) {
Expand Down

0 comments on commit 7c0e93c

Please sign in to comment.