summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-04-29 17:24:34 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-04-29 17:24:34 +0000
commit87b5017139e9d8ac9b046b3284a9cc68c76185d6 (patch)
treeceda3137641902b9f35259515b770c20cf4cf9e2 /lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
parentefa91f6475f6e96552986104ab4857db46185a2a (diff)
downloadllvm-87b5017139e9d8ac9b046b3284a9cc68c76185d6.tar.gz
llvm-87b5017139e9d8ac9b046b3284a9cc68c76185d6.tar.bz2
llvm-87b5017139e9d8ac9b046b3284a9cc68c76185d6.tar.xz
Propagate relocation info to resolveRelocation.
This gets most of the MCJITs tests passing with MachO. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180716 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp')
-rw-r--r--lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
index af55ed34a9..9a6048c410 100644
--- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
+++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
@@ -21,16 +21,24 @@ using namespace llvm::object;
namespace llvm {
+void RuntimeDyldMachO::resolveRelocation(const RelocationEntry &RE,
+ uint64_t Value) {
+ const SectionEntry &Section = Sections[RE.SectionID];
+ return resolveRelocation(Section, RE.Offset, Value, RE.RelType, RE.Addend,
+ RE.IsPCRel, RE.Size);
+}
+
void RuntimeDyldMachO::resolveRelocation(const SectionEntry &Section,
uint64_t Offset,
uint64_t Value,
uint32_t Type,
- int64_t Addend) {
+ int64_t Addend,
+ bool isPCRel,
+ unsigned LogSize) {
uint8_t *LocalAddress = Section.Address + Offset;
uint64_t FinalAddress = Section.LoadAddress + Offset;
- bool isPCRel = (Type >> 24) & 1;
- unsigned MachoType = (Type >> 28) & 0xf;
- unsigned Size = 1 << ((Type >> 25) & 3);
+ unsigned MachoType = Type;
+ unsigned Size = 1 << LogSize;
DEBUG(dbgs() << "resolveRelocation LocalAddress: "
<< format("%p", LocalAddress)
@@ -220,6 +228,8 @@ void RuntimeDyldMachO::processRelocationRef(unsigned SectionID,
SectionEntry &Section = Sections[SectionID];
bool isExtern = MachO->getPlainRelocationExternal(RE);
+ bool IsPCRel = MachO->getAnyRelocationPCRel(RE);
+ unsigned Size = MachO->getAnyRelocationLength(RE);
if (isExtern) {
// Obtain the symbol name which is referenced in the relocation
SymbolRef Symbol;
@@ -276,7 +286,7 @@ void RuntimeDyldMachO::processRelocationRef(unsigned SectionID,
if (i != Stubs.end())
resolveRelocation(Section, Offset,
(uint64_t)Section.Address + i->second,
- RelType, 0);
+ RelType, 0, IsPCRel, Size);
else {
// Create a new stub function.
Stubs[Value] = Section.StubOffset;
@@ -290,11 +300,12 @@ void RuntimeDyldMachO::processRelocationRef(unsigned SectionID,
addRelocationForSection(RE, Value.SectionID);
resolveRelocation(Section, Offset,
(uint64_t)Section.Address + Section.StubOffset,
- RelType, 0);
+ RelType, 0, IsPCRel, Size);
Section.StubOffset += getMaxStubSize();
}
} else {
- RelocationEntry RE(SectionID, Offset, RelType, Value.Addend);
+ RelocationEntry RE(SectionID, Offset, RelType, Value.Addend,
+ IsPCRel, Size);
if (Value.SymbolName)
addRelocationForSymbol(RE, Value.SymbolName);
else