1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
//===------- 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<SPSRemoteSymbolLookupSetElement,
SymbolLookupSet::value_type> {
public:
static size_t size(const SymbolLookupSet::value_type &V) {
return SPSArgList<SPSString, bool>::size(
*V.first, V.second == SymbolLookupFlags::RequiredSymbol);
}
static bool serialize(SPSOutputBuffer &OB,
const SymbolLookupSet::value_type &V) {
return SPSArgList<SPSString, bool>::serialize(
OB, *V.first, V.second == SymbolLookupFlags::RequiredSymbol);
}
};
template <>
class TrivialSPSSequenceSerialization<SPSRemoteSymbolLookupSetElement,
SymbolLookupSet> {
public:
static constexpr bool available = true;
};
template <>
class SPSSerializationTraits<SPSRemoteSymbolLookup,
ExecutorProcessControl::LookupRequest> {
using MemberSerialization =
SPSArgList<SPSExecutorAddr, SPSRemoteSymbolLookupSet>;
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>
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<tpctypes::DylibHandle> EPCGenericDylibManager::open(StringRef Path,
uint64_t Mode) {
Expected<tpctypes::DylibHandle> H(0);
if (auto Err =
EPC.callSPSWrapper<rt::SPSSimpleExecutorDylibManagerOpenSignature>(
SAs.Open, H, SAs.Instance, Path, Mode))
return std::move(Err);
return H;
}
Expected<std::vector<ExecutorAddr>>
EPCGenericDylibManager::lookup(tpctypes::DylibHandle H,
const SymbolLookupSet &Lookup) {
Expected<std::vector<ExecutorAddr>> Result((std::vector<ExecutorAddr>()));
if (auto Err =
EPC.callSPSWrapper<rt::SPSSimpleExecutorDylibManagerLookupSignature>(
SAs.Lookup, Result, SAs.Instance, H, Lookup))
return std::move(Err);
return Result;
}
Expected<std::vector<ExecutorAddr>>
EPCGenericDylibManager::lookup(tpctypes::DylibHandle H,
const RemoteSymbolLookupSet &Lookup) {
Expected<std::vector<ExecutorAddr>> Result((std::vector<ExecutorAddr>()));
if (auto Err =
EPC.callSPSWrapper<rt::SPSSimpleExecutorDylibManagerLookupSignature>(
SAs.Lookup, Result, SAs.Instance, H, Lookup))
return std::move(Err);
return Result;
}
} // end namespace orc
} // end namespace llvm
|