LLVM 19.0.0git
Classes | Public Member Functions | Static Public Member Functions | List of all members
llvm::orc::ELFNixPlatform Class Reference

Mediates between ELFNix initialization and ExecutionSession state. More...

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

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

Public Member Functions

ExecutionSessiongetExecutionSession () const
 
ObjectLinkingLayergetObjectLinkingLayer () const
 
Error setupJITDylib (JITDylib &JD) override
 This method will be called outside the session lock each time a JITDylib is created (unless it is created with EmptyJITDylib set) to allow the Platform to install any JITDylib specific standard symbols (e.g __dso_handle).
 
Error teardownJITDylib (JITDylib &JD) override
 This method will be called outside the session lock each time a JITDylib is removed to allow the Platform to remove any JITDylib-specific data.
 
Error notifyAdding (ResourceTracker &RT, const MaterializationUnit &MU) override
 This method will be called under the ExecutionSession lock each time a MaterializationUnit is added to a JITDylib.
 
Error notifyRemoving (ResourceTracker &RT) override
 This method will be called under the ExecutionSession lock when a ResourceTracker is removed.
 
- Public Member Functions inherited from llvm::orc::Platform
virtual ~Platform ()
 
virtual Error setupJITDylib (JITDylib &JD)=0
 This method will be called outside the session lock each time a JITDylib is created (unless it is created with EmptyJITDylib set) to allow the Platform to install any JITDylib specific standard symbols (e.g __dso_handle).
 
virtual Error teardownJITDylib (JITDylib &JD)=0
 This method will be called outside the session lock each time a JITDylib is removed to allow the Platform to remove any JITDylib-specific data.
 
virtual Error notifyAdding (ResourceTracker &RT, const MaterializationUnit &MU)=0
 This method will be called under the ExecutionSession lock each time a MaterializationUnit is added to a JITDylib.
 
virtual Error notifyRemoving (ResourceTracker &RT)=0
 This method will be called under the ExecutionSession lock when a ResourceTracker is removed.
 

Static Public Member Functions

static Expected< std::unique_ptr< ELFNixPlatform > > Create (ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, std::unique_ptr< DefinitionGenerator > OrcRuntime, std::optional< SymbolAliasMap > RuntimeAliases=std::nullopt)
 Try to create a ELFNixPlatform instance, adding the ORC runtime to the given JITDylib.
 
static Expected< std::unique_ptr< ELFNixPlatform > > Create (ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, const char *OrcRuntimePath, std::optional< SymbolAliasMap > RuntimeAliases=std::nullopt)
 Construct using a path to the ORC runtime.
 
static Expected< SymbolAliasMapstandardPlatformAliases (ExecutionSession &ES, JITDylib &PlatformJD)
 Returns an AliasMap containing the default aliases for the ELFNixPlatform.
 
static ArrayRef< std::pair< const char *, const char * > > requiredCXXAliases ()
 Returns the array of required CXX aliases.
 
static ArrayRef< std::pair< const char *, const char * > > standardRuntimeUtilityAliases ()
 Returns the array of standard runtime utility aliases for ELF.
 
- Static Public Member Functions inherited from llvm::orc::Platform
static Expected< DenseMap< JITDylib *, SymbolMap > > lookupInitSymbols (ExecutionSession &ES, const DenseMap< JITDylib *, SymbolLookupSet > &InitSyms)
 A utility function for looking up initializer symbols.
 
static void lookupInitSymbolsAsync (unique_function< void(Error)> OnComplete, ExecutionSession &ES, const DenseMap< JITDylib *, SymbolLookupSet > &InitSyms)
 Performs an async lookup for the given symbols in each of the given JITDylibs, calling the given handler once all lookups have completed.
 

Detailed Description

Mediates between ELFNix initialization and ExecutionSession state.

Definition at line 55 of file ELFNixPlatform.h.

Member Function Documentation

◆ Create() [1/2]

Expected< std::unique_ptr< ELFNixPlatform > > llvm::orc::ELFNixPlatform::Create ( ExecutionSession ES,
ObjectLinkingLayer ObjLinkingLayer,
JITDylib PlatformJD,
const char OrcRuntimePath,
std::optional< SymbolAliasMap RuntimeAliases = std::nullopt 
)
static

Construct using a path to the ORC runtime.

Definition at line 160 of file ELFNixPlatform.cpp.

References Create(), and llvm::orc::StaticLibraryDefinitionGenerator::Load().

◆ Create() [2/2]

Expected< std::unique_ptr< ELFNixPlatform > > llvm::orc::ELFNixPlatform::Create ( ExecutionSession ES,
ObjectLinkingLayer ObjLinkingLayer,
JITDylib PlatformJD,
std::unique_ptr< DefinitionGenerator OrcRuntime,
std::optional< SymbolAliasMap RuntimeAliases = std::nullopt 
)
static

Try to create a ELFNixPlatform instance, adding the ORC runtime to the given JITDylib.

The ORC runtime requires access to a number of symbols in libc++. It is up to the caller to ensure that the required symbols can be referenced by code added to PlatformJD. The standard way to achieve this is to first attach dynamic library search generators for either the given process, or for the specific required libraries, to PlatformJD, then to create the platform instance:

auto &PlatformJD = ES.createBareJITDylib("stdlib");
PlatformJD.addGenerator(
::GetForTargetProcess(EPC)));
ExitOnErr(ELFNixPlatform::Create(ES, ObjLayer, EPC, PlatformJD,
"/path/to/orc/runtime")));
static Expected< std::unique_ptr< ELFNixPlatform > > Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, std::unique_ptr< DefinitionGenerator > OrcRuntime, std::optional< SymbolAliasMap > RuntimeAliases=std::nullopt)
Try to create a ELFNixPlatform instance, adding the ORC runtime to the given JITDylib.
void setPlatform(std::unique_ptr< Platform > P)
Set the Platform for this ExecutionSession.
Definition: Core.h:1491
JITDylib & createBareJITDylib(std::string Name)
Add a new bare JITDylib to this ExecutionSession.
Definition: Core.cpp:1666
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
Definition: Core.h:1905

Alternatively, these symbols could be added to another JITDylib that PlatformJD links against.

Clients are also responsible for ensuring that any JIT'd code that depends on runtime functions (including any code using TLV or static destructors) can reference the runtime symbols. This is usually achieved by linking any JITDylibs containing regular code against PlatformJD.

By default, ELFNixPlatform will add the set of aliases returned by the standardPlatformAliases function. This includes both required aliases (e.g. __cxa_atexit -> __orc_rt_elf_cxa_atexit for static destructor support), and optional aliases that provide JIT versions of common functions (e.g. dlopen -> __orc_rt_elf_jit_dlopen). Clients can override these defaults by passing a non-None value for the RuntimeAliases function, in which case the client is responsible for setting up all aliases (including the required ones).

Definition at line 115 of file ELFNixPlatform.cpp.

References llvm::orc::absoluteSymbols(), llvm::orc::JITDylib::define(), llvm::JITSymbolFlags::Exported, llvm::orc::ExecutionSession::getExecutorProcessControl(), llvm::orc::ExecutionSession::getTargetTriple(), llvm::inconvertibleErrorCode(), llvm::orc::ExecutionSession::intern(), P, standardPlatformAliases(), llvm::Triple::str(), llvm::Error::success(), and llvm::orc::symbolAliases().

Referenced by Create(), and llvm::orc::ExecutorNativePlatform::operator()().

◆ getExecutionSession()

ExecutionSession & llvm::orc::ELFNixPlatform::getExecutionSession ( ) const
inline

Definition at line 106 of file ELFNixPlatform.h.

◆ getObjectLinkingLayer()

ObjectLinkingLayer & llvm::orc::ELFNixPlatform::getObjectLinkingLayer ( ) const
inline

Definition at line 107 of file ELFNixPlatform.h.

◆ notifyAdding()

Error llvm::orc::ELFNixPlatform::notifyAdding ( ResourceTracker RT,
const MaterializationUnit MU 
)
overridevirtual

◆ notifyRemoving()

Error llvm::orc::ELFNixPlatform::notifyRemoving ( ResourceTracker RT)
overridevirtual

This method will be called under the ExecutionSession lock when a ResourceTracker is removed.

Implements llvm::orc::Platform.

Definition at line 201 of file ELFNixPlatform.cpp.

References llvm_unreachable.

◆ requiredCXXAliases()

ArrayRef< std::pair< const char *, const char * > > llvm::orc::ELFNixPlatform::requiredCXXAliases ( )
static

Returns the array of required CXX aliases.

Definition at line 225 of file ELFNixPlatform.cpp.

Referenced by standardPlatformAliases().

◆ setupJITDylib()

Error llvm::orc::ELFNixPlatform::setupJITDylib ( JITDylib JD)
overridevirtual

This method will be called outside the session lock each time a JITDylib is created (unless it is created with EmptyJITDylib set) to allow the Platform to install any JITDylib specific standard symbols (e.g __dso_handle).

Implements llvm::orc::Platform.

Definition at line 176 of file ELFNixPlatform.cpp.

References llvm::orc::JITDylib::define().

◆ standardPlatformAliases()

Expected< SymbolAliasMap > llvm::orc::ELFNixPlatform::standardPlatformAliases ( ExecutionSession ES,
JITDylib PlatformJD 
)
static

Returns an AliasMap containing the default aliases for the ELFNixPlatform.

This can be modified by clients when constructing the platform to add or remove aliases.

Definition at line 216 of file ELFNixPlatform.cpp.

References llvm::orc::addAliases(), requiredCXXAliases(), and standardRuntimeUtilityAliases().

Referenced by Create().

◆ standardRuntimeUtilityAliases()

ArrayRef< std::pair< const char *, const char * > > llvm::orc::ELFNixPlatform::standardRuntimeUtilityAliases ( )
static

Returns the array of standard runtime utility aliases for ELF.

Definition at line 234 of file ELFNixPlatform.cpp.

Referenced by standardPlatformAliases().

◆ teardownJITDylib()

Error llvm::orc::ELFNixPlatform::teardownJITDylib ( JITDylib JD)
overridevirtual

This method will be called outside the session lock each time a JITDylib is removed to allow the Platform to remove any JITDylib-specific data.

Implements llvm::orc::Platform.

Definition at line 181 of file ELFNixPlatform.cpp.

References llvm::Error::success().


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