1 //===--------------- SimpleExecutorDylibManager.h ---------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // A simple dynamic library management class. Allows dynamic libraries to be 10 // loaded and searched. 11 // 12 // FIXME: The functionality in this file should be moved to the ORC runtime. 13 // 14 //===----------------------------------------------------------------------===// 15 16 #ifndef LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORDYLIBMANAGER_H 17 #define LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORDYLIBMANAGER_H 18 19 #include "llvm/ADT/DenseSet.h" 20 #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h" 21 #include "llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h" 22 #include "llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h" 23 #include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h" 24 #include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h" 25 #include "llvm/ExecutionEngine/Orc/TargetProcess/ExecutorBootstrapService.h" 26 #include "llvm/Support/DynamicLibrary.h" 27 #include "llvm/Support/Error.h" 28 29 #include <mutex> 30 31 namespace llvm { 32 namespace orc { 33 namespace rt_bootstrap { 34 35 /// Simple page-based allocator. 36 class SimpleExecutorDylibManager : public ExecutorBootstrapService { 37 public: 38 virtual ~SimpleExecutorDylibManager(); 39 40 Expected<tpctypes::DylibHandle> open(const std::string &Path, uint64_t Mode); 41 Expected<std::vector<ExecutorSymbolDef>> 42 lookup(tpctypes::DylibHandle H, const RemoteSymbolLookupSet &L); 43 44 Error shutdown() override; 45 void addBootstrapSymbols(StringMap<ExecutorAddr> &M) override; 46 47 private: 48 using DylibSet = DenseSet<void *>; 49 50 static llvm::orc::shared::CWrapperFunctionResult 51 openWrapper(const char *ArgData, size_t ArgSize); 52 53 static llvm::orc::shared::CWrapperFunctionResult 54 lookupWrapper(const char *ArgData, size_t ArgSize); 55 56 std::mutex M; 57 DylibSet Dylibs; 58 }; 59 60 } // end namespace rt_bootstrap 61 } // end namespace orc 62 } // end namespace llvm 63 64 #endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_SIMPLEEXECUTORDYLIBMANAGER_H 65