diff options
author | dim <dim@FreeBSD.org> | 2015-02-26 07:20:05 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-02-26 07:20:05 +0000 |
commit | ea2f309a40278ff24b148e983999100320aa809c (patch) | |
tree | dc28b080328800c6bf82455e49df56dea1ca1dd0 /contrib/libcxxrt | |
parent | 4d42a57ca7d462cd6864605668e90006e5b03750 (diff) | |
download | FreeBSD-src-ea2f309a40278ff24b148e983999100320aa809c.zip FreeBSD-src-ea2f309a40278ff24b148e983999100320aa809c.tar.gz |
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 <aoyama@peach.ne.jp>
Reviewed by: imp, bapt
Tested by: bapt
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D1967
Diffstat (limited to 'contrib/libcxxrt')
-rw-r--r-- | contrib/libcxxrt/dwarf_eh.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/contrib/libcxxrt/dwarf_eh.h b/contrib/libcxxrt/dwarf_eh.h index af533b3..da86846 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<uint64_t>(*reinterpret_cast<type*>(*data));\ - *data += sizeof(type);\ - break; + {\ + type t;\ + memcpy(&t, *data, sizeof t);\ + *data += sizeof t;\ + return static_cast<uint64_t>(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; } /** |