[llvm] r192732 - Fixing some host==target assumptions in RuntimeDyld
Andrew Kaylor
andrew.kaylor at intel.com
Tue Oct 15 13:44:55 PDT 2013
Author: akaylor
Date: Tue Oct 15 15:44:55 2013
New Revision: 192732
URL: http://llvm.org/viewvc/llvm-project?rev=192732&view=rev
Log:
Fixing some host==target assumptions in RuntimeDyld
Modified:
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=192732&r1=192731&r2=192732&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Tue Oct 15 15:44:55 2013
@@ -74,7 +74,9 @@ ObjectImage *RuntimeDyldImpl::loadObject
if (!obj)
report_fatal_error("Unable to create object image from memory buffer!");
+ // Save information about our target
Arch = (Triple::ArchType)obj->getArch();
+ IsTargetLittleEndian = obj->getObjectFile()->isLittleEndian();
// Symbols found in this object
StringMap<SymbolLoc> LocalSymbols;
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h?rev=192732&r1=192731&r2=192732&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h Tue Oct 15 15:44:55 2013
@@ -184,6 +184,7 @@ protected:
typedef std::map<RelocationValueRef, uintptr_t> StubMap;
Triple::ArchType Arch;
+ bool IsTargetLittleEndian;
inline unsigned getMaxStubSize() {
if (Arch == Triple::aarch64)
@@ -228,14 +229,14 @@ protected:
}
void writeInt16BE(uint8_t *Addr, uint16_t Value) {
- if (sys::IsLittleEndianHost)
+ if (IsTargetLittleEndian)
Value = sys::SwapByteOrder(Value);
*Addr = (Value >> 8) & 0xFF;
*(Addr+1) = Value & 0xFF;
}
void writeInt32BE(uint8_t *Addr, uint32_t Value) {
- if (sys::IsLittleEndianHost)
+ if (IsTargetLittleEndian)
Value = sys::SwapByteOrder(Value);
*Addr = (Value >> 24) & 0xFF;
*(Addr+1) = (Value >> 16) & 0xFF;
@@ -244,7 +245,7 @@ protected:
}
void writeInt64BE(uint8_t *Addr, uint64_t Value) {
- if (sys::IsLittleEndianHost)
+ if (IsTargetLittleEndian)
Value = sys::SwapByteOrder(Value);
*Addr = (Value >> 56) & 0xFF;
*(Addr+1) = (Value >> 48) & 0xFF;
More information about the llvm-commits
mailing list