Index: include/llvm/ExecutionEngine/RuntimeDyld.h =================================================================== --- include/llvm/ExecutionEngine/RuntimeDyld.h +++ include/llvm/ExecutionEngine/RuntimeDyld.h @@ -184,8 +184,13 @@ bool FinalizationLocked = false; }; + typedef std::function( + const object::ObjectFile &O)> + DyldImplCreateFtor; + /// \brief Construct a RuntimeDyld instance. - RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver); + RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver, + DyldImplCreateFtor = nullptr); RuntimeDyld(const RuntimeDyld &) = delete; void operator=(const RuntimeDyld &) = delete; ~RuntimeDyld(); @@ -256,10 +261,14 @@ /// void finalizeWithMemoryManagerLocking(); + /// Gets pointer to implementation + RuntimeDyldImpl *getImpl(); + private: // RuntimeDyldImpl is the actual class. RuntimeDyld is just the public // interface. std::unique_ptr Dyld; + DyldImplCreateFtor DyldCreator; MemoryManager &MemMgr; JITSymbolResolver &Resolver; bool ProcessAllSections; Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp =================================================================== --- lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -996,8 +996,9 @@ void JITSymbolResolver::anchor() {} RuntimeDyld::RuntimeDyld(RuntimeDyld::MemoryManager &MemMgr, - JITSymbolResolver &Resolver) - : MemMgr(MemMgr), Resolver(Resolver) { + JITSymbolResolver &Resolver, + DyldImplCreateFtor DyldCreator) + : DyldCreator(DyldCreator), MemMgr(MemMgr), Resolver(Resolver) { // FIXME: There's a potential issue lurking here if a single instance of // RuntimeDyld is used to load multiple objects. The current implementation // associates a single memory manager with a RuntimeDyld instance. Even @@ -1048,7 +1049,9 @@ std::unique_ptr RuntimeDyld::loadObject(const ObjectFile &Obj) { if (!Dyld) { - if (Obj.isELF()) + if (DyldCreator) + Dyld = DyldCreator(Obj); + else if (Obj.isELF()) Dyld = createRuntimeDyldELF(static_cast(Obj.getArch()), MemMgr, Resolver, ProcessAllSections, Checker); @@ -1110,6 +1113,8 @@ } } +RuntimeDyldImpl *RuntimeDyld::getImpl() { return Dyld.get(); } + void RuntimeDyld::registerEHFrames() { if (Dyld) Dyld->registerEHFrames();