From 409421cc9bd1baa4eb32bcf6f0acdd0a776a1c7f Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 1 Mar 2015 00:47:37 +0000 Subject: [PATCH] MFC r279307: Make libcxxrt's parsing of DWARF exception handling tables work on architectures with strict alignment, by using memcpy() instead of directly reading fields. Reported by: Daisuke Aoyama Reviewed by: imp, bapt Tested by: bapt Differential Revision: https://reviews.freebsd.org/D1967 MFC r279310: Since newer versions of compiler-rt require unwind.h, and we want to use the copy in libcxxrt for it, fix the arm-specific header to define the _Unwind_Action type. Submitted by: andrew git-svn-id: svn://svn.freebsd.org/base/stable/10@279456 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- contrib/libcxxrt/dwarf_eh.h | 18 ++++++++---------- contrib/libcxxrt/unwind-arm.h | 2 ++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib/libcxxrt/dwarf_eh.h b/contrib/libcxxrt/dwarf_eh.h index af533b346..da86846ab 100644 --- a/contrib/libcxxrt/dwarf_eh.h +++ b/contrib/libcxxrt/dwarf_eh.h @@ -218,15 +218,17 @@ static int64_t read_sleb128(dw_eh_ptr_t *data) static uint64_t read_value(char encoding, dw_eh_ptr_t *data) { enum dwarf_data_encoding type = get_encoding(encoding); - uint64_t v; switch (type) { // Read fixed-length types #define READ(dwarf, type) \ case dwarf:\ - v = static_cast(*reinterpret_cast(*data));\ - *data += sizeof(type);\ - break; + {\ + type t;\ + memcpy(&t, *data, sizeof t);\ + *data += sizeof t;\ + return static_cast(t);\ + } READ(DW_EH_PE_udata2, uint16_t) READ(DW_EH_PE_udata4, uint32_t) READ(DW_EH_PE_udata8, uint64_t) @@ -237,15 +239,11 @@ static uint64_t read_value(char encoding, dw_eh_ptr_t *data) #undef READ // Read variable-length types case DW_EH_PE_sleb128: - v = read_sleb128(data); - break; + return read_sleb128(data); case DW_EH_PE_uleb128: - v = read_uleb128(data); - break; + return read_uleb128(data); default: abort(); } - - return v; } /** diff --git a/contrib/libcxxrt/unwind-arm.h b/contrib/libcxxrt/unwind-arm.h index 52e563e41..23f2b79f7 100644 --- a/contrib/libcxxrt/unwind-arm.h +++ b/contrib/libcxxrt/unwind-arm.h @@ -36,6 +36,8 @@ _URC_FATAL_PHASE1_ERROR = _URC_FAILURE } _Unwind_Reason_Code; +typedef int _Unwind_Action; + typedef uint32_t _Unwind_State; #ifdef __clang__ static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME = 0; -- 2.45.0