Index: src/cxa_personality.cpp =================================================================== --- src/cxa_personality.cpp +++ src/cxa_personality.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include "config.h" @@ -141,6 +142,19 @@ namespace __cxxabiv1 { +namespace +{ + +template +uintptr_t readPointerHelper(const uint8_t*& p) { + FromType from; + memcpy(&from, (void*)p, sizeof(FromType)); + p += sizeof(FromType); + return static_cast(from); +} + +} // end namespace + extern "C" { @@ -245,28 +259,22 @@ result = static_cast(readSLEB128(&p)); break; case DW_EH_PE_udata2: - result = *((uint16_t*)p); - p += sizeof(uint16_t); + result = readPointerHelper(p); break; case DW_EH_PE_udata4: - result = *((uint32_t*)p); - p += sizeof(uint32_t); + result = readPointerHelper(p); break; case DW_EH_PE_udata8: - result = static_cast(*((uint64_t*)p)); - p += sizeof(uint64_t); + result = readPointerHelper(p); break; case DW_EH_PE_sdata2: - result = static_cast(*((int16_t*)p)); - p += sizeof(int16_t); + result = readPointerHelper(p); break; case DW_EH_PE_sdata4: - result = static_cast(*((int32_t*)p)); - p += sizeof(int32_t); + result = readPointerHelper(p); break; case DW_EH_PE_sdata8: - result = static_cast(*((int64_t*)p)); - p += sizeof(int64_t); + result = readPointerHelper(p); break; default: // not supported