summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.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/RuntimeDyldELF.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/RuntimeDyldELF.cpp')
-rw-r--r--lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
index f2c69fc99c..ec9193120d 100644
--- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -25,6 +25,8 @@
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/ELF.h"
+#include "llvm/Support/MemoryBuffer.h"
+
using namespace llvm;
using namespace llvm::object;
@@ -178,6 +180,39 @@ void RuntimeDyldELF::deregisterEHFrames() {
RegisteredEHFrameSections.clear();
}
+ObjectImage *RuntimeDyldELF::createObjectImageFromFile(object::ObjectFile *ObjFile) {
+ if (!ObjFile)
+ return NULL;
+
+ error_code ec;
+ MemoryBuffer* Buffer = MemoryBuffer::getMemBuffer(ObjFile->getData(),
+ "",
+ false);
+
+ if (ObjFile->getBytesInAddress() == 4 && ObjFile->isLittleEndian()) {
+ DyldELFObject<ELFType<support::little, 2, false> > *Obj =
+ new DyldELFObject<ELFType<support::little, 2, false> >(Buffer, ec);
+ return new ELFObjectImage<ELFType<support::little, 2, false> >(NULL, Obj);
+ }
+ else if (ObjFile->getBytesInAddress() == 4 && !ObjFile->isLittleEndian()) {
+ DyldELFObject<ELFType<support::big, 2, false> > *Obj =
+ new DyldELFObject<ELFType<support::big, 2, false> >(Buffer, ec);
+ return new ELFObjectImage<ELFType<support::big, 2, false> >(NULL, Obj);
+ }
+ else if (ObjFile->getBytesInAddress() == 8 && !ObjFile->isLittleEndian()) {
+ DyldELFObject<ELFType<support::big, 2, true> > *Obj =
+ new DyldELFObject<ELFType<support::big, 2, true> >(Buffer, ec);
+ return new ELFObjectImage<ELFType<support::big, 2, true> >(NULL, Obj);
+ }
+ else if (ObjFile->getBytesInAddress() == 8 && ObjFile->isLittleEndian()) {
+ DyldELFObject<ELFType<support::little, 2, true> > *Obj =
+ new DyldELFObject<ELFType<support::little, 2, true> >(Buffer, ec);
+ return new ELFObjectImage<ELFType<support::little, 2, true> >(NULL, Obj);
+ }
+ else
+ llvm_unreachable("Unexpected ELF format");
+}
+
ObjectImage *RuntimeDyldELF::createObjectImage(ObjectBuffer *Buffer) {
if (Buffer->getBufferSize() < ELF::EI_NIDENT)
llvm_unreachable("Unexpected ELF object size");
@@ -1403,4 +1438,9 @@ bool RuntimeDyldELF::isCompatibleFormat(const ObjectBuffer *Buffer) const {
return false;
return (memcmp(Buffer->getBufferStart(), ELF::ElfMagic, strlen(ELF::ElfMagic))) == 0;
}
+
+bool RuntimeDyldELF::isCompatibleFile(const object::ObjectFile *Obj) const {
+ return Obj->isELF();
+}
+
} // namespace llvm