Skip to content

Commit b3c9ced

Browse files
committed
[ORC] Allow EPCDebugObjectRegistrar clients to specify registration fn dylib.
Similar to the EPCEHFrameRegistrar change in c977251, this allows clients who have sourced a dylib handle via a side-channel to search that dylib to find the registration functions. This patch defaults to the existing behavior in the case where the client does not specify a handle to use.
1 parent 9000ee2 commit b3c9ced

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ class EPCDebugObjectRegistrar : public DebugObjectRegistrar {
5050
};
5151

5252
/// Create a ExecutorProcessControl-based DebugObjectRegistrar that emits debug
53-
/// objects to the GDB JIT interface.
54-
Expected<std::unique_ptr<EPCDebugObjectRegistrar>>
55-
createJITLoaderGDBRegistrar(ExecutionSession &ES);
53+
/// objects to the GDB JIT interface. This will use the EPC's lookupSymbols
54+
/// method to find the registration/deregistration funciton addresses by name.
55+
///
56+
/// If RegistrationFunctionsDylib is non-None then it will be searched to find
57+
/// the registration functions. If it is None then the process dylib will be
58+
/// loaded to find the registration functions.
59+
Expected<std::unique_ptr<EPCDebugObjectRegistrar>> createJITLoaderGDBRegistrar(
60+
ExecutionSession &ES,
61+
Optional<ExecutorAddr> RegistrationFunctionDylib = None);
5662

5763
} // end namespace orc
5864
} // end namespace llvm

llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@ namespace llvm {
1717
namespace orc {
1818

1919
Expected<std::unique_ptr<EPCDebugObjectRegistrar>>
20-
createJITLoaderGDBRegistrar(ExecutionSession &ES) {
20+
createJITLoaderGDBRegistrar(ExecutionSession &ES,
21+
Optional<ExecutorAddr> RegistrationFunctionDylib) {
2122
auto &EPC = ES.getExecutorProcessControl();
22-
auto ProcessHandle = EPC.loadDylib(nullptr);
23-
if (!ProcessHandle)
24-
return ProcessHandle.takeError();
23+
24+
if (!RegistrationFunctionDylib) {
25+
if (auto D = EPC.loadDylib(nullptr))
26+
RegistrationFunctionDylib = *D;
27+
else
28+
return D.takeError();
29+
}
2530

2631
SymbolStringPtr RegisterFn =
2732
EPC.getTargetTriple().isOSBinFormatMachO()
@@ -31,7 +36,8 @@ createJITLoaderGDBRegistrar(ExecutionSession &ES) {
3136
SymbolLookupSet RegistrationSymbols;
3237
RegistrationSymbols.add(RegisterFn);
3338

34-
auto Result = EPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}});
39+
auto Result =
40+
EPC.lookupSymbols({{*RegistrationFunctionDylib, RegistrationSymbols}});
3541
if (!Result)
3642
return Result.takeError();
3743

0 commit comments

Comments
 (0)