diff options
author | Lang Hames <lhames@gmail.com> | 2014-08-18 21:43:16 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2014-08-18 21:43:16 +0000 |
commit | 4f867bfada573f775e22c7564abe5502f1665a67 (patch) | |
tree | 9045c29307168c1eb7cc1712c10bfddd92feacef /llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp | |
parent | baac2afccf744a7274553a1ea0df5b40e1bcfa63 (diff) | |
download | llvm-4f867bfada573f775e22c7564abe5502f1665a67.zip llvm-4f867bfada573f775e22c7564abe5502f1665a67.tar.gz llvm-4f867bfada573f775e22c7564abe5502f1665a67.tar.bz2 |
[MCJIT] Respect target endianness in RuntimeDyldMachO and RuntimeDyldChecker.
This patch may address some of the issues described in http://llvm.org/PR20640.
llvm-svn: 215938
Diffstat (limited to 'llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp index d244f45..02504a9 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp @@ -705,7 +705,16 @@ uint64_t RuntimeDyldCheckerImpl::readMemoryAtAddr(uint64_t SrcAddr, assert(PtrSizedAddr == SrcAddr && "Linker memory pointer out-of-range."); uint8_t *Src = reinterpret_cast<uint8_t *>(PtrSizedAddr); uint64_t Result = 0; - memcpy(&Result, Src, Size); + + // If host and target endianness match use memcpy, otherwise copy in reverse + // order. + if (getRTDyld().IsTargetLittleEndian == sys::IsLittleEndianHost) + memcpy(&Result, Src, Size); + else { + uint8_t *Dst = reinterpret_cast<uint8_t*>(&Result) + Size - 1; + for (unsigned i = 0; i < Size; ++i) + *Dst-- = *Src++; + } return Result; } |