diff options
author | Sean Callanan <scallanan@apple.com> | 2012-03-26 20:45:52 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2012-03-26 20:45:52 +0000 |
commit | b38aae442f0e3ce11a6231455b180bfc66ab5d3e (patch) | |
tree | 2bbac9fc3bbf45358004ace19418ed7ed233d335 /lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp | |
parent | c71108b6f843f39d4a305e6d351e4a2be4f604b2 (diff) |
Made RuntimeDyldMachO support vanilla i386
relocations. The algorithm is the same as
that for x86_64. Scattered relocations, a
feature present in i386 but not on x86_64,
are not yet supported.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153466 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp')
-rw-r--r-- | lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index 0b72b567c3..7130e0e174 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -32,6 +32,14 @@ resolveRelocation(uint8_t *LocalAddress, // This just dispatches to the proper target specific routine. switch (CPUType) { default: llvm_unreachable("Unsupported CPU type!"); + case mach::CTM_i386: + return resolveI386Relocation(LocalAddress, + FinalAddress, + (uintptr_t)Value, + isPCRel, + Type, + Size, + Addend); case mach::CTM_x86_64: return resolveX86_64Relocation(LocalAddress, FinalAddress, @@ -52,6 +60,35 @@ resolveRelocation(uint8_t *LocalAddress, } bool RuntimeDyldMachO:: +resolveI386Relocation(uint8_t *LocalAddress, + uint64_t FinalAddress, + uint64_t Value, + bool isPCRel, + unsigned Type, + unsigned Size, + int64_t Addend) { + if (isPCRel) + Value -= FinalAddress + 4; // see resolveX86_64Relocation + + switch (Type) { + default: + llvm_unreachable("Invalid relocation type!"); + case macho::RIT_Vanilla: { + uint8_t *p = LocalAddress; + uint64_t ValueToWrite = Value + Addend; + for (unsigned i = 0; i < Size; ++i) { + *p++ = (uint8_t)(ValueToWrite & 0xff); + ValueToWrite >>= 8; + } + } + case macho::RIT_Difference: + case macho::RIT_Generic_LocalDifference: + case macho::RIT_Generic_PreboundLazyPointer: + return Error("Relocation type not implemented yet!"); + } +} + +bool RuntimeDyldMachO:: resolveX86_64Relocation(uint8_t *LocalAddress, uint64_t FinalAddress, uint64_t Value, |