1 //===------- EPCGenericDylibManager.cpp -- Dylib management via EPC -------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/EPCGenericDylibManager.h"
11 #include "llvm/ExecutionEngine/Orc/Core.h"
12 #include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
13 #include "llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h"
20 class SPSSerializationTraits
<SPSRemoteSymbolLookupSetElement
,
21 SymbolLookupSet::value_type
> {
23 static size_t size(const SymbolLookupSet::value_type
&V
) {
24 return SPSArgList
<SPSString
, bool>::size(
25 *V
.first
, V
.second
== SymbolLookupFlags::RequiredSymbol
);
28 static bool serialize(SPSOutputBuffer
&OB
,
29 const SymbolLookupSet::value_type
&V
) {
30 return SPSArgList
<SPSString
, bool>::serialize(
31 OB
, *V
.first
, V
.second
== SymbolLookupFlags::RequiredSymbol
);
36 class TrivialSPSSequenceSerialization
<SPSRemoteSymbolLookupSetElement
,
39 static constexpr bool available
= true;
43 class SPSSerializationTraits
<SPSRemoteSymbolLookup
,
44 ExecutorProcessControl::LookupRequest
> {
45 using MemberSerialization
=
46 SPSArgList
<SPSExecutorAddr
, SPSRemoteSymbolLookupSet
>;
49 static size_t size(const ExecutorProcessControl::LookupRequest
&LR
) {
50 return MemberSerialization::size(ExecutorAddr(LR
.Handle
), LR
.Symbols
);
53 static bool serialize(SPSOutputBuffer
&OB
,
54 const ExecutorProcessControl::LookupRequest
&LR
) {
55 return MemberSerialization::serialize(OB
, ExecutorAddr(LR
.Handle
),
60 } // end namespace shared
62 Expected
<EPCGenericDylibManager
>
63 EPCGenericDylibManager::CreateWithDefaultBootstrapSymbols(
64 ExecutorProcessControl
&EPC
) {
66 if (auto Err
= EPC
.getBootstrapSymbols(
67 {{SAs
.Instance
, rt::SimpleExecutorDylibManagerInstanceName
},
68 {SAs
.Open
, rt::SimpleExecutorDylibManagerOpenWrapperName
},
69 {SAs
.Lookup
, rt::SimpleExecutorDylibManagerLookupWrapperName
}}))
70 return std::move(Err
);
71 return EPCGenericDylibManager(EPC
, std::move(SAs
));
74 Expected
<tpctypes::DylibHandle
> EPCGenericDylibManager::open(StringRef Path
,
76 Expected
<tpctypes::DylibHandle
> H((ExecutorAddr()));
78 EPC
.callSPSWrapper
<rt::SPSSimpleExecutorDylibManagerOpenSignature
>(
79 SAs
.Open
, H
, SAs
.Instance
, Path
, Mode
))
80 return std::move(Err
);
84 Expected
<std::vector
<ExecutorSymbolDef
>>
85 EPCGenericDylibManager::lookup(tpctypes::DylibHandle H
,
86 const SymbolLookupSet
&Lookup
) {
87 Expected
<std::vector
<ExecutorSymbolDef
>> Result(
88 (std::vector
<ExecutorSymbolDef
>()));
90 EPC
.callSPSWrapper
<rt::SPSSimpleExecutorDylibManagerLookupSignature
>(
91 SAs
.Lookup
, Result
, SAs
.Instance
, H
, Lookup
))
92 return std::move(Err
);
96 Expected
<std::vector
<ExecutorSymbolDef
>>
97 EPCGenericDylibManager::lookup(tpctypes::DylibHandle H
,
98 const RemoteSymbolLookupSet
&Lookup
) {
99 Expected
<std::vector
<ExecutorSymbolDef
>> Result(
100 (std::vector
<ExecutorSymbolDef
>()));
102 EPC
.callSPSWrapper
<rt::SPSSimpleExecutorDylibManagerLookupSignature
>(
103 SAs
.Lookup
, Result
, SAs
.Instance
, H
, Lookup
))
104 return std::move(Err
);
108 } // end namespace orc
109 } // end namespace llvm