summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-04-29 14:44:23 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-04-29 14:44:23 +0000
commitefa91f6475f6e96552986104ab4857db46185a2a (patch)
treeca2131ee0a54a67ba719e01fb4ff990191e1d8e7 /lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
parentf4fc9b175306a49c3d3c72f1e9e08f8ea2038c51 (diff)
downloadllvm-efa91f6475f6e96552986104ab4857db46185a2a.tar.gz
llvm-efa91f6475f6e96552986104ab4857db46185a2a.tar.bz2
llvm-efa91f6475f6e96552986104ab4857db46185a2a.tar.xz
Replace ObjRelocationInfo with relocation_iterator.
For MachO we need information that is not represented in ObjRelocationInfo. Instead of copying the bits we think are needed from a relocation_iterator, just pass the relocation_iterator down to the format specific functions. No functionality change yet as we still drop the information once processRelocationRef returns. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180711 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp')
-rw-r--r--lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
index bcc3df1b4e..af55ed34a9 100644
--- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
+++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
@@ -205,21 +205,26 @@ bool RuntimeDyldMachO::resolveARMRelocation(uint8_t *LocalAddress,
return false;
}
-void RuntimeDyldMachO::processRelocationRef(const ObjRelocationInfo &Rel,
+void RuntimeDyldMachO::processRelocationRef(unsigned SectionID,
+ relocation_iterator RelI,
ObjectImage &Obj,
ObjSectionToIDMap &ObjSectionToID,
const SymbolTableMap &Symbols,
StubMap &Stubs) {
+ const ObjectFile *OF = Obj.getObjectFile();
+ const MachOObjectFile *MachO = static_cast<const MachOObjectFile*>(OF);
+ macho::RelocationEntry RE = MachO->getRelocation(RelI->getRawDataRefImpl());
- uint32_t RelType = (uint32_t) (Rel.Type & 0xffffffffL);
+ uint32_t RelType = MachO->getAnyRelocationType(RE);
RelocationValueRef Value;
- SectionEntry &Section = Sections[Rel.SectionID];
+ SectionEntry &Section = Sections[SectionID];
- bool isExtern = (RelType >> 27) & 1;
+ bool isExtern = MachO->getPlainRelocationExternal(RE);
if (isExtern) {
// Obtain the symbol name which is referenced in the relocation
+ SymbolRef Symbol;
+ RelI->getSymbol(Symbol);
StringRef TargetName;
- const SymbolRef &Symbol = Rel.Symbol;
Symbol.getName(TargetName);
// First search for the symbol in the local symbol table
SymbolTableMap::const_iterator lsi = Symbols.find(TargetName.data());
@@ -261,13 +266,15 @@ void RuntimeDyldMachO::processRelocationRef(const ObjRelocationInfo &Rel,
}
}
+ uint64_t Offset;
+ RelI->getOffset(Offset);
if (Arch == Triple::arm && (RelType & 0xf) == macho::RIT_ARM_Branch24Bit) {
// This is an ARM branch relocation, need to use a stub function.
// Look up for existing stub.
StubMap::const_iterator i = Stubs.find(Value);
if (i != Stubs.end())
- resolveRelocation(Section, Rel.Offset,
+ resolveRelocation(Section, Offset,
(uint64_t)Section.Address + i->second,
RelType, 0);
else {
@@ -275,19 +282,19 @@ void RuntimeDyldMachO::processRelocationRef(const ObjRelocationInfo &Rel,
Stubs[Value] = Section.StubOffset;
uint8_t *StubTargetAddr = createStubFunction(Section.Address +
Section.StubOffset);
- RelocationEntry RE(Rel.SectionID, StubTargetAddr - Section.Address,
+ RelocationEntry RE(SectionID, StubTargetAddr - Section.Address,
macho::RIT_Vanilla, Value.Addend);
if (Value.SymbolName)
addRelocationForSymbol(RE, Value.SymbolName);
else
addRelocationForSection(RE, Value.SectionID);
- resolveRelocation(Section, Rel.Offset,
+ resolveRelocation(Section, Offset,
(uint64_t)Section.Address + Section.StubOffset,
RelType, 0);
Section.StubOffset += getMaxStubSize();
}
} else {
- RelocationEntry RE(Rel.SectionID, Rel.Offset, RelType, Value.Addend);
+ RelocationEntry RE(SectionID, Offset, RelType, Value.Addend);
if (Value.SymbolName)
addRelocationForSymbol(RE, Value.SymbolName);
else