summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2014-01-08 04:09:09 +0000
committerLang Hames <lhames@gmail.com>2014-01-08 04:09:09 +0000
commit42fdb1f00ffc5d0a0326f11cadaeec1c26691688 (patch)
tree5294abeb5fb8c95d81ced305ed1a9d5d0ba7849b /lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
parent0fe78d5669e37cf9c5b613ef56b4e5a2de975271 (diff)
downloadllvm-42fdb1f00ffc5d0a0326f11cadaeec1c26691688.tar.gz
llvm-42fdb1f00ffc5d0a0326f11cadaeec1c26691688.tar.bz2
llvm-42fdb1f00ffc5d0a0326f11cadaeec1c26691688.tar.xz
Re-apply r196639: Add support for archives and object file caching under MCJIT.
I believe the bot failures on linux systems were due to overestimating the alignment of object-files within archives, which are only guaranteed to be two-byte aligned. I have reduced the alignment in RuntimeDyldELF::createObjectImageFromFile accordingly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198737 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp')
-rw-r--r--lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index 14e867d7c1..f99d7d0b27 100644
--- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -82,12 +82,24 @@ ObjectImage *RuntimeDyldImpl::createObjectImage(ObjectBuffer *InputBuffer) {
return new ObjectImageCommon(InputBuffer);
}
+ObjectImage *RuntimeDyldImpl::createObjectImageFromFile(ObjectFile *InputObject) {
+ return new ObjectImageCommon(InputObject);
+}
+
+ObjectImage *RuntimeDyldImpl::loadObject(ObjectFile *InputObject) {
+ return loadObject(createObjectImageFromFile(InputObject));
+}
+
ObjectImage *RuntimeDyldImpl::loadObject(ObjectBuffer *InputBuffer) {
+ return loadObject(createObjectImage(InputBuffer));
+}
+
+ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) {
MutexGuard locked(lock);
- OwningPtr<ObjectImage> obj(createObjectImage(InputBuffer));
+ OwningPtr<ObjectImage> obj(InputObject);
if (!obj)
- report_fatal_error("Unable to create object image from memory buffer!");
+ return NULL;
// Save information about our target
Arch = (Triple::ArchType)obj->getArch();
@@ -139,7 +151,7 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectBuffer *InputBuffer) {
if (si == obj->end_sections()) continue;
Check(si->getContents(SectionData));
Check(si->isText(IsCode));
- const uint8_t* SymPtr = (const uint8_t*)InputBuffer->getBufferStart() +
+ const uint8_t* SymPtr = (const uint8_t*)InputObject->getData().data() +
(uintptr_t)FileOffset;
uintptr_t SectOffset = (uintptr_t)(SymPtr -
(const uint8_t*)SectionData.begin());
@@ -563,6 +575,22 @@ RuntimeDyld::~RuntimeDyld() {
delete Dyld;
}
+ObjectImage *RuntimeDyld::loadObject(ObjectFile *InputObject) {
+ if (!Dyld) {
+ if (InputObject->isELF())
+ Dyld = new RuntimeDyldELF(MM);
+ else if (InputObject->isMachO())
+ Dyld = new RuntimeDyldMachO(MM);
+ else
+ report_fatal_error("Incompatible object format!");
+ } else {
+ if (!Dyld->isCompatibleFile(InputObject))
+ report_fatal_error("Incompatible object format!");
+ }
+
+ return Dyld->loadObject(InputObject);
+}
+
ObjectImage *RuntimeDyld::loadObject(ObjectBuffer *InputBuffer) {
if (!Dyld) {
sys::fs::file_magic Type =