/// Create from a ExecutorProcessControl instance alone. This will use
/// the EPC's lookupSymbols method to find the registration/deregistration
/// funciton addresses by name.
+ ///
+ /// If RegistrationFunctionsDylib is non-None then it will be searched to
+ /// find the registration functions. If it is None then the process dylib
+ /// will be loaded to find the registration functions.
static Expected<std::unique_ptr<EPCEHFrameRegistrar>>
- Create(ExecutionSession &ES);
+ Create(ExecutionSession &ES,
+ Optional<ExecutorAddr> RegistrationFunctionsDylib = None);
/// Create a EPCEHFrameRegistrar with the given ExecutorProcessControl
/// object and registration/deregistration function addresses.
namespace orc {
Expected<std::unique_ptr<EPCEHFrameRegistrar>>
-EPCEHFrameRegistrar::Create(ExecutionSession &ES) {
+EPCEHFrameRegistrar::Create(ExecutionSession &ES,
+ Optional<ExecutorAddr> RegistrationFunctionsDylib) {
// FIXME: Proper mangling here -- we really need to decouple linker mangling
// from DataLayout.
// Find the addresses of the registration/deregistration functions in the
// executor process.
auto &EPC = ES.getExecutorProcessControl();
- auto ProcessHandle = EPC.loadDylib(nullptr);
- if (!ProcessHandle)
- return ProcessHandle.takeError();
+
+ if (!RegistrationFunctionsDylib) {
+ if (auto D = EPC.loadDylib(nullptr))
+ RegistrationFunctionsDylib = *D;
+ else
+ return D.takeError();
+ }
std::string RegisterWrapperName, DeregisterWrapperName;
if (EPC.getTargetTriple().isOSBinFormatMachO()) {
RegistrationSymbols.add(EPC.intern(RegisterWrapperName));
RegistrationSymbols.add(EPC.intern(DeregisterWrapperName));
- auto Result = EPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}});
+ auto Result =
+ EPC.lookupSymbols({{*RegistrationFunctionsDylib, RegistrationSymbols}});
if (!Result)
return Result.takeError();