summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp')
-rw-r--r--contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp86
1 files changed, 52 insertions, 34 deletions
diff --git a/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index 409b25f..a08b508 100644
--- a/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -25,10 +25,15 @@ using namespace llvm::object;
// Empty out-of-line virtual destructor as the key function.
RTDyldMemoryManager::~RTDyldMemoryManager() {}
+void RTDyldMemoryManager::registerEHFrames(StringRef SectionData) {}
RuntimeDyldImpl::~RuntimeDyldImpl() {}
namespace llvm {
+StringRef RuntimeDyldImpl::getEHFrameSection() {
+ return StringRef();
+}
+
// Resolve the relocations for all symbols we currently know about.
void RuntimeDyldImpl::resolveRelocations() {
// First, resolve relocations associated with external symbols.
@@ -96,7 +101,8 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectBuffer *InputBuffer) {
bool isCommon = flags & SymbolRef::SF_Common;
if (isCommon) {
// Add the common symbols to a list. We'll allocate them all below.
- uint64_t Align = getCommonSymbolAlignment(*i);
+ uint32_t Align;
+ Check(i->getAlignment(Align));
uint64_t Size = 0;
Check(i->getSize(Size));
CommonSize += Size + Align;
@@ -154,18 +160,8 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectBuffer *InputBuffer) {
isFirstRelocation = false;
}
- ObjRelocationInfo RI;
- RI.SectionID = SectionID;
- Check(i->getAdditionalInfo(RI.AdditionalInfo));
- Check(i->getOffset(RI.Offset));
- Check(i->getSymbol(RI.Symbol));
- Check(i->getType(RI.Type));
-
- DEBUG(dbgs() << "\t\tAddend: " << RI.AdditionalInfo
- << " Offset: " << format("%p", (uintptr_t)RI.Offset)
- << " Type: " << (uint32_t)(RI.Type & 0xffffffffL)
- << "\n");
- processRelocationRef(RI, *obj, LocalSections, LocalSymbols, Stubs);
+ processRelocationRef(SectionID, *i, *obj, LocalSections, LocalSymbols,
+ Stubs);
}
}
@@ -183,7 +179,7 @@ void RuntimeDyldImpl::emitCommonSymbols(ObjectImage &Obj,
if (!Addr)
report_fatal_error("Unable to allocate memory for common symbols!");
uint64_t Offset = 0;
- Sections.push_back(SectionEntry(StringRef(), Addr, TotalSize, TotalSize, 0));
+ Sections.push_back(SectionEntry(StringRef(), Addr, TotalSize, 0));
memset(Addr, 0, TotalSize);
DEBUG(dbgs() << "emitCommonSection SectionID: " << SectionID
@@ -243,6 +239,12 @@ unsigned RuntimeDyldImpl::emitSection(ObjectImage &Obj,
Check(Section.isReadOnlyData(IsReadOnly));
Check(Section.getSize(DataSize));
Check(Section.getName(Name));
+ if (StubSize > 0) {
+ unsigned StubAlignment = getStubAlignment();
+ unsigned EndAlignment = (DataSize | Alignment) & -(DataSize | Alignment);
+ if (StubAlignment > EndAlignment)
+ StubBufSize += StubAlignment - EndAlignment;
+ }
unsigned Allocate;
unsigned SectionID = Sections.size();
@@ -295,8 +297,7 @@ unsigned RuntimeDyldImpl::emitSection(ObjectImage &Obj,
<< "\n");
}
- Sections.push_back(SectionEntry(Name, Addr, Allocate, DataSize,
- (uintptr_t)pData));
+ Sections.push_back(SectionEntry(Name, Addr, DataSize, (uintptr_t)pData));
return SectionID;
}
@@ -339,7 +340,25 @@ void RuntimeDyldImpl::addRelocationForSymbol(const RelocationEntry &RE,
}
uint8_t *RuntimeDyldImpl::createStubFunction(uint8_t *Addr) {
- if (Arch == Triple::arm) {
+ if (Arch == Triple::aarch64) {
+ // This stub has to be able to access the full address space,
+ // since symbol lookup won't necessarily find a handy, in-range,
+ // PLT stub for functions which could be anywhere.
+ uint32_t *StubAddr = (uint32_t*)Addr;
+
+ // Stub can use ip0 (== x16) to calculate address
+ *StubAddr = 0xd2e00010; // movz ip0, #:abs_g3:<addr>
+ StubAddr++;
+ *StubAddr = 0xf2c00010; // movk ip0, #:abs_g2_nc:<addr>
+ StubAddr++;
+ *StubAddr = 0xf2a00010; // movk ip0, #:abs_g1_nc:<addr>
+ StubAddr++;
+ *StubAddr = 0xf2800010; // movk ip0, #:abs_g0_nc:<addr>
+ StubAddr++;
+ *StubAddr = 0xd61f0200; // br ip0
+
+ return Addr;
+ } else if (Arch == Triple::arm) {
// TODO: There is only ARM far stub now. We should add the Thumb stub,
// and stubs for branches Thumb - ARM and ARM - Thumb.
uint32_t *StubAddr = (uint32_t*)Addr;
@@ -380,6 +399,13 @@ uint8_t *RuntimeDyldImpl::createStubFunction(uint8_t *Addr) {
writeInt32BE(Addr+40, 0x4E800420); // bctr
return Addr;
+ } else if (Arch == Triple::systemz) {
+ writeInt16BE(Addr, 0xC418); // lgrl %r1,.+8
+ writeInt16BE(Addr+2, 0x0000);
+ writeInt16BE(Addr+4, 0x0004);
+ writeInt16BE(Addr+6, 0x07F1); // brc 15,%r1
+ // 8-byte address stored at Addr + 8
+ return Addr;
}
return Addr;
}
@@ -401,26 +427,14 @@ void RuntimeDyldImpl::reassignSectionAddress(unsigned SectionID,
Sections[SectionID].LoadAddress = Addr;
}
-void RuntimeDyldImpl::resolveRelocationEntry(const RelocationEntry &RE,
- uint64_t Value) {
- // Ignore relocations for sections that were not loaded
- if (Sections[RE.SectionID].Address != 0) {
- DEBUG(dbgs() << "\tSectionID: " << RE.SectionID
- << " + " << RE.Offset << " ("
- << format("%p", Sections[RE.SectionID].Address + RE.Offset) << ")"
- << " RelType: " << RE.RelType
- << " Addend: " << RE.Addend
- << "\n");
-
- resolveRelocation(Sections[RE.SectionID], RE.Offset,
- Value, RE.RelType, RE.Addend);
- }
-}
-
void RuntimeDyldImpl::resolveRelocationList(const RelocationList &Relocs,
uint64_t Value) {
for (unsigned i = 0, e = Relocs.size(); i != e; ++i) {
- resolveRelocationEntry(Relocs[i], Value);
+ const RelocationEntry &RE = Relocs[i];
+ // Ignore relocations for sections that were not loaded
+ if (Sections[RE.SectionID].Address == 0)
+ continue;
+ resolveRelocation(RE, Value);
}
}
@@ -534,4 +548,8 @@ StringRef RuntimeDyld::getErrorString() {
return Dyld->getErrorString();
}
+StringRef RuntimeDyld::getEHFrameSection() {
+ return Dyld->getEHFrameSection();
+}
+
} // end namespace llvm
OpenPOWER on IntegriCloud