//===------- EPCGenericDylibManager.cpp -- Dylib management via EPC -------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "llvm/ExecutionEngine/Orc/EPCGenericDylibManager.h" #include "llvm/ExecutionEngine/Orc/Core.h" #include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h" #include "llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h" namespace llvm { namespace orc { namespace shared { template <> class SPSSerializationTraits { public: static size_t size(const SymbolLookupSet::value_type &V) { return SPSArgList::size( *V.first, V.second == SymbolLookupFlags::RequiredSymbol); } static bool serialize(SPSOutputBuffer &OB, const SymbolLookupSet::value_type &V) { return SPSArgList::serialize( OB, *V.first, V.second == SymbolLookupFlags::RequiredSymbol); } }; template <> class TrivialSPSSequenceSerialization { public: static constexpr bool available = true; }; template <> class SPSSerializationTraits { using MemberSerialization = SPSArgList; public: static size_t size(const ExecutorProcessControl::LookupRequest &LR) { return MemberSerialization::size(ExecutorAddr(LR.Handle), LR.Symbols); } static bool serialize(SPSOutputBuffer &OB, const ExecutorProcessControl::LookupRequest &LR) { return MemberSerialization::serialize(OB, ExecutorAddr(LR.Handle), LR.Symbols); } }; } // end namespace shared Expected EPCGenericDylibManager::CreateWithDefaultBootstrapSymbols( ExecutorProcessControl &EPC) { SymbolAddrs SAs; if (auto Err = EPC.getBootstrapSymbols( {{SAs.Instance, rt::SimpleExecutorDylibManagerInstanceName}, {SAs.Open, rt::SimpleExecutorDylibManagerOpenWrapperName}, {SAs.Lookup, rt::SimpleExecutorDylibManagerLookupWrapperName}})) return std::move(Err); return EPCGenericDylibManager(EPC, std::move(SAs)); } Expected EPCGenericDylibManager::open(StringRef Path, uint64_t Mode) { Expected H((ExecutorAddr())); if (auto Err = EPC.callSPSWrapper( SAs.Open, H, SAs.Instance, Path, Mode)) return std::move(Err); return H; } Expected> EPCGenericDylibManager::lookup(tpctypes::DylibHandle H, const SymbolLookupSet &Lookup) { Expected> Result((std::vector())); if (auto Err = EPC.callSPSWrapper( SAs.Lookup, Result, SAs.Instance, H, Lookup)) return std::move(Err); return Result; } Expected> EPCGenericDylibManager::lookup(tpctypes::DylibHandle H, const RemoteSymbolLookupSet &Lookup) { Expected> Result((std::vector())); if (auto Err = EPC.callSPSWrapper( SAs.Lookup, Result, SAs.Instance, H, Lookup)) return std::move(Err); return Result; } } // end namespace orc } // end namespace llvm