From: Lang Hames Date: Thu, 29 Oct 2015 03:52:58 +0000 (+0000) Subject: [Orc] Add support for RuntimeDyld::setProcessAllSections. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=22bbdbd7678ba72547453334561c7eb2dcd258b1 [Orc] Add support for RuntimeDyld::setProcessAllSections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251604 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h b/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h index 5ba0bb21afd..2acfecfb94d 100644 --- a/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h +++ b/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h @@ -39,9 +39,12 @@ protected: void operator=(const LinkedObjectSet&) = delete; public: LinkedObjectSet(RuntimeDyld::MemoryManager &MemMgr, - RuntimeDyld::SymbolResolver &Resolver) + RuntimeDyld::SymbolResolver &Resolver, + bool ProcessAllSections) : RTDyld(llvm::make_unique(MemMgr, Resolver)), - State(Raw) {} + State(Raw) { + RTDyld->setProcessAllSections(ProcessAllSections); + } virtual ~LinkedObjectSet() {} @@ -98,9 +101,10 @@ private: class ConcreteLinkedObjectSet : public LinkedObjectSet { public: ConcreteLinkedObjectSet(MemoryManagerPtrT MemMgr, - SymbolResolverPtrT Resolver) - : LinkedObjectSet(*MemMgr, *Resolver), MemMgr(std::move(MemMgr)), - Resolver(std::move(Resolver)) { } + SymbolResolverPtrT Resolver, + bool ProcessAllSections) + : LinkedObjectSet(*MemMgr, *Resolver, ProcessAllSections), + MemMgr(std::move(MemMgr)), Resolver(std::move(Resolver)) { } void Finalize() override { State = Finalizing; @@ -117,9 +121,11 @@ private: template std::unique_ptr - createLinkedObjectSet(MemoryManagerPtrT MemMgr, SymbolResolverPtrT Resolver) { + createLinkedObjectSet(MemoryManagerPtrT MemMgr, SymbolResolverPtrT Resolver, + bool ProcessAllSections) { typedef ConcreteLinkedObjectSet LOS; - return llvm::make_unique(std::move(MemMgr), std::move(Resolver)); + return llvm::make_unique(std::move(MemMgr), std::move(Resolver), + ProcessAllSections); } public: @@ -138,7 +144,18 @@ public: NotifyLoadedFtor NotifyLoaded = NotifyLoadedFtor(), NotifyFinalizedFtor NotifyFinalized = NotifyFinalizedFtor()) : NotifyLoaded(std::move(NotifyLoaded)), - NotifyFinalized(std::move(NotifyFinalized)) {} + NotifyFinalized(std::move(NotifyFinalized)), + ProcessAllSections(false) {} + + /// @brief Set the 'ProcessAllSections' flag. + /// + /// If set to true, all sections in each object file will be allocated using + /// the memory manager, rather than just the sections required for execution. + /// + /// This is kludgy, and may be removed in the future. + void setProcessAllSections(bool ProcessAllSections) { + this->ProcessAllSections = ProcessAllSections; + } /// @brief Add a set of objects (or archives) that will be treated as a unit /// for the purposes of symbol lookup and memory management. @@ -160,7 +177,8 @@ public: ObjSetHandleT Handle = LinkedObjSetList.insert( LinkedObjSetList.end(), - createLinkedObjectSet(std::move(MemMgr), std::move(Resolver))); + createLinkedObjectSet(std::move(MemMgr), std::move(Resolver), + ProcessAllSections)); LinkedObjectSet &LOS = **Handle; LoadedObjInfoList LoadedObjInfos; @@ -256,6 +274,7 @@ private: LinkedObjectSetListT LinkedObjSetList; NotifyLoadedFtor NotifyLoaded; NotifyFinalizedFtor NotifyFinalized; + bool ProcessAllSections; }; } // End namespace orc. diff --git a/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h b/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h index 42770fcdcae..d1aff5a1a0a 100644 --- a/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h +++ b/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h @@ -230,6 +230,10 @@ public: CompileLayer.setObjectCache(NewCache); } + void setProcessAllSections(bool ProcessAllSections) override { + ObjectLayer.setProcessAllSections(ProcessAllSections); + } + private: RuntimeDyld::SymbolInfo findMangledSymbol(StringRef Name) { diff --git a/unittests/ExecutionEngine/Orc/CMakeLists.txt b/unittests/ExecutionEngine/Orc/CMakeLists.txt index 01c209f8e0e..047cea68cec 100644 --- a/unittests/ExecutionEngine/Orc/CMakeLists.txt +++ b/unittests/ExecutionEngine/Orc/CMakeLists.txt @@ -12,6 +12,7 @@ add_llvm_unittest(OrcJITTests IndirectionUtilsTest.cpp GlobalMappingLayerTest.cpp LazyEmittingLayerTest.cpp + ObjectLinkingLayerTest.cpp ObjectTransformLayerTest.cpp OrcCAPITest.cpp OrcTestCommon.cpp