aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2014-08-18 21:43:16 +0000
committerLang Hames <lhames@gmail.com>2014-08-18 21:43:16 +0000
commit4f867bfada573f775e22c7564abe5502f1665a67 (patch)
tree9045c29307168c1eb7cc1712c10bfddd92feacef /llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
parentbaac2afccf744a7274553a1ea0df5b40e1bcfa63 (diff)
downloadllvm-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.cpp11
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;
}