#include <assert.h>
#include <stdlib.h>
+#include <string.h>
#include <typeinfo>
#include "config.h"
namespace __cxxabiv1
{
+namespace
+{
+
+template <class AsType>
+uintptr_t readPointerHelper(const uint8_t*& p) {
+ AsType value;
+ memcpy(&value, const_cast<uint8_t*>(p), sizeof(AsType));
+ p += sizeof(AsType);
+ return static_cast<uintptr_t>(value);
+}
+
+} // end namespace
+
extern "C"
{
result = static_cast<uintptr_t>(readSLEB128(&p));
break;
case DW_EH_PE_udata2:
- result = *((uint16_t*)p);
- p += sizeof(uint16_t);
+ result = readPointerHelper<uint16_t>(p);
break;
case DW_EH_PE_udata4:
- result = *((uint32_t*)p);
- p += sizeof(uint32_t);
+ result = readPointerHelper<uint32_t>(p);
break;
case DW_EH_PE_udata8:
- result = static_cast<uintptr_t>(*((uint64_t*)p));
- p += sizeof(uint64_t);
+ result = readPointerHelper<uint64_t>(p);
break;
case DW_EH_PE_sdata2:
- result = static_cast<uintptr_t>(*((int16_t*)p));
- p += sizeof(int16_t);
+ result = readPointerHelper<int16_t>(p);
break;
case DW_EH_PE_sdata4:
- result = static_cast<uintptr_t>(*((int32_t*)p));
- p += sizeof(int32_t);
+ result = readPointerHelper<int32_t>(p);
break;
case DW_EH_PE_sdata8:
- result = static_cast<uintptr_t>(*((int64_t*)p));
- p += sizeof(int64_t);
+ result = readPointerHelper<int64_t>(p);
break;
default:
// not supported