LLVM 20.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::orc::DynamicLibrarySearchGenerator Class Reference

A utility class to expose symbols found via dlsym to the JIT. More...

#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"

Inheritance diagram for llvm::orc::DynamicLibrarySearchGenerator:
Inheritance graph
[legend]

Public Types

using SymbolPredicate = std::function< bool(const SymbolStringPtr &)>
 
using AddAbsoluteSymbolsFn = unique_function< Error(JITDylib &, SymbolMap)>
 

Public Member Functions

 DynamicLibrarySearchGenerator (sys::DynamicLibrary Dylib, char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)
 Create a DynamicLibrarySearchGenerator that searches for symbols in the given sys::DynamicLibrary.
 
Error tryToGenerate (LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) override
 DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
 
- Public Member Functions inherited from llvm::orc::DefinitionGenerator
virtual ~DefinitionGenerator ()
 
virtual Error tryToGenerate (LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &LookupSet)=0
 DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
 

Static Public Member Functions

static Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > Load (const char *FileName, char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)
 Permanently loads the library at the given path and, on success, returns a DynamicLibrarySearchGenerator that will search it for symbol definitions in the library.
 
static Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > GetForCurrentProcess (char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)
 Creates a DynamicLibrarySearchGenerator that searches for symbols in the current process.
 

Detailed Description

A utility class to expose symbols found via dlsym to the JIT.

If an instance of this class is attached to a JITDylib as a fallback definition generator, then any symbol found in the given DynamicLibrary that passes the 'Allow' predicate will be added to the JITDylib.

Definition at line 216 of file ExecutionUtils.h.

Member Typedef Documentation

◆ AddAbsoluteSymbolsFn

Definition at line 219 of file ExecutionUtils.h.

◆ SymbolPredicate

Definition at line 218 of file ExecutionUtils.h.

Constructor & Destructor Documentation

◆ DynamicLibrarySearchGenerator()

llvm::orc::DynamicLibrarySearchGenerator::DynamicLibrarySearchGenerator ( sys::DynamicLibrary  Dylib,
char  GlobalPrefix,
SymbolPredicate  Allow = SymbolPredicate(),
AddAbsoluteSymbolsFn  AddAbsoluteSymbols = nullptr 
)

Create a DynamicLibrarySearchGenerator that searches for symbols in the given sys::DynamicLibrary.

If the Allow predicate is given then only symbols matching the predicate will be searched for. If the predicate is not given then all symbols will be searched for.

If AddAbsoluteSymbols is provided, it is used to add the symbols to the JITDylib; otherwise it uses JD.define(absoluteSymbols(...)).

Definition at line 222 of file ExecutionUtils.cpp.

Member Function Documentation

◆ GetForCurrentProcess()

static Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > llvm::orc::DynamicLibrarySearchGenerator::GetForCurrentProcess ( char  GlobalPrefix,
SymbolPredicate  Allow = SymbolPredicate(),
AddAbsoluteSymbolsFn  AddAbsoluteSymbols = nullptr 
)
inlinestatic

Creates a DynamicLibrarySearchGenerator that searches for symbols in the current process.

Definition at line 246 of file ExecutionUtils.h.

References GlobalPrefix, and Load().

Referenced by LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess().

◆ Load()

Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > llvm::orc::DynamicLibrarySearchGenerator::Load ( const char FileName,
char  GlobalPrefix,
SymbolPredicate  Allow = SymbolPredicate(),
AddAbsoluteSymbolsFn  AddAbsoluteSymbols = nullptr 
)
static

Permanently loads the library at the given path and, on success, returns a DynamicLibrarySearchGenerator that will search it for symbol definitions in the library.

On failure returns the reason the library failed to load.

Definition at line 230 of file ExecutionUtils.cpp.

References llvm::sys::DynamicLibrary::getPermanentLibrary(), GlobalPrefix, llvm::inconvertibleErrorCode(), and llvm::Lib.

Referenced by GetForCurrentProcess(), and LLVMOrcCreateDynamicLibrarySearchGeneratorForPath().

◆ tryToGenerate()

Error llvm::orc::DynamicLibrarySearchGenerator::tryToGenerate ( LookupState LS,
LookupKind  K,
JITDylib JD,
JITDylibLookupFlags  JDLookupFlags,
const SymbolLookupSet LookupSet 
)
overridevirtual

DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.

K specifies the kind of this lookup. JD specifies the target JITDylib being searched, and JDLookupFlags specifies whether the search should match against hidden symbols. Finally, Symbols describes the set of unresolved symbols and their associated lookup flags.

Implements llvm::orc::DefinitionGenerator.

Definition at line 242 of file ExecutionUtils.cpp.

References llvm::orc::absoluteSymbols(), llvm::orc::JITDylib::define(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::JITSymbolFlags::Exported, llvm::orc::ExecutorAddr::fromPtr(), llvm::sys::DynamicLibrary::getAddressOfSymbol(), Name, P, and llvm::Error::success().


The documentation for this class was generated from the following files: