summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
diff options
context:
space:
mode:
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..68e86d86b6 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, 4, false> > *Obj =
+ new DyldELFObject<ELFType<support::little, 4, false> >(Buffer, ec);
+ return new ELFObjectImage<ELFType<support::little, 4, false> >(NULL, Obj);
+ }
+ else if (ObjFile->getBytesInAddress() == 4 && !ObjFile->isLittleEndian()) {
+ DyldELFObject<ELFType<support::big, 4, false> > *Obj =
+ new DyldELFObject<ELFType<support::big, 4, false> >(Buffer, ec);
+ return new ELFObjectImage<ELFType<support::big, 4, false> >(NULL, Obj);
+ }
+ else if (ObjFile->getBytesInAddress() == 8 && !ObjFile->isLittleEndian()) {
+ DyldELFObject<ELFType<support::big, 8, true> > *Obj =
+ new DyldELFObject<ELFType<support::big, 8, true> >(Buffer, ec);
+ return new ELFObjectImage<ELFType<support::big, 8, true> >(NULL, Obj);
+ }
+ else if (ObjFile->getBytesInAddress() == 8 && ObjFile->isLittleEndian()) {
+ DyldELFObject<ELFType<support::little, 8, true> > *Obj =
+ new DyldELFObject<ELFType<support::little, 8, true> >(Buffer, ec);
+ return new ELFObjectImage<ELFType<support::little, 8, 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