LLVM 19.0.0git
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes | List of all members
llvm::RTDyldMemoryManager Class Reference

#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"

Inheritance diagram for llvm::RTDyldMemoryManager:
Inheritance graph
[legend]

Classes

struct  EHFrame
 

Public Member Functions

 RTDyldMemoryManager ()=default
 
 RTDyldMemoryManager (const RTDyldMemoryManager &)=delete
 
void operator= (const RTDyldMemoryManager &)=delete
 
 ~RTDyldMemoryManager () override
 
void registerEHFrames (uint8_t *Addr, uint64_t LoadAddr, size_t Size) override
 Register the EH frames with the runtime so that c++ exceptions work.
 
void deregisterEHFrames () override
 
virtual uint64_t getSymbolAddress (const std::string &Name)
 Legacy symbol lookup - DEPRECATED! Please override findSymbol instead.
 
JITSymbol findSymbol (const std::string &Name) override
 This method returns a RuntimeDyld::SymbolInfo for the specified function or variable.
 
virtual uint64_t getSymbolAddressInLogicalDylib (const std::string &Name)
 Legacy symbol lookup – DEPRECATED! Please override findSymbolInLogicalDylib instead.
 
JITSymbol findSymbolInLogicalDylib (const std::string &Name) override
 Default to treating all modules as separate.
 
virtual void * getPointerToNamedFunction (const std::string &Name, bool AbortOnFailure=true)
 This method returns the address of the specified function.
 
- Public Member Functions inherited from llvm::MCJITMemoryManager
virtual void notifyObjectLoaded (ExecutionEngine *EE, const object::ObjectFile &)
 This method is called after an object has been loaded into memory but before relocations are applied to the loaded sections.
 
- Public Member Functions inherited from llvm::RuntimeDyld::MemoryManager
 MemoryManager ()=default
 
virtual ~MemoryManager ()=default
 
virtual uint8_t * allocateCodeSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName)=0
 Allocate a memory block of (at least) the given size suitable for executable code.
 
virtual uint8_t * allocateDataSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, bool IsReadOnly)=0
 Allocate a memory block of (at least) the given size suitable for data.
 
virtual TLSSection allocateTLSSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName)
 Allocate a memory block of (at least) the given size to be used for thread-local storage (TLS).
 
virtual void reserveAllocationSpace (uintptr_t CodeSize, Align CodeAlign, uintptr_t RODataSize, Align RODataAlign, uintptr_t RWDataSize, Align RWDataAlign)
 Inform the memory manager about the total amount of memory required to allocate all sections to be loaded: CodeSize - the total size of all code sections DataSizeRO - the total size of all read-only data sections DataSizeRW - the total size of all read-write data sections.
 
virtual bool needsToReserveAllocationSpace ()
 Override to return true to enable the reserveAllocationSpace callback.
 
virtual bool allowStubAllocation () const
 Override to return false to tell LLVM no stub space will be needed.
 
virtual void registerEHFrames (uint8_t *Addr, uint64_t LoadAddr, size_t Size)=0
 Register the EH frames with the runtime so that c++ exceptions work.
 
virtual void deregisterEHFrames ()=0
 
virtual bool finalizeMemory (std::string *ErrMsg=nullptr)=0
 This method is called when object loading is complete and section page permissions can be applied.
 
virtual void notifyObjectLoaded (RuntimeDyld &RTDyld, const object::ObjectFile &Obj)
 This method is called after an object has been loaded into memory but before relocations are applied to the loaded sections.
 
- Public Member Functions inherited from llvm::LegacyJITSymbolResolver
void lookup (const LookupSet &Symbols, OnResolvedFunction OnResolved) final
 Performs lookup by, for each symbol, first calling findSymbolInLogicalDylib and if that fails calling findSymbol.
 
Expected< LookupSetgetResponsibilitySet (const LookupSet &Symbols) final
 Performs flags lookup by calling findSymbolInLogicalDylib and returning the flags value for that symbol.
 
virtual JITSymbol findSymbolInLogicalDylib (const std::string &Name)=0
 This method returns the address of the specified symbol if it exists within the logical dynamic library represented by this JITSymbolResolver.
 
virtual JITSymbol findSymbol (const std::string &Name)=0
 This method returns the address of the specified function or variable.
 
- Public Member Functions inherited from llvm::JITSymbolResolver
virtual ~JITSymbolResolver ()=default
 
virtual void lookup (const LookupSet &Symbols, OnResolvedFunction OnResolved)=0
 Returns the fully resolved address and flags for each of the given symbols.
 
virtual Expected< LookupSetgetResponsibilitySet (const LookupSet &Symbols)=0
 Returns the subset of the given symbols that should be materialized by the caller.
 
virtual bool allowsZeroSymbols ()
 Specify if this resolver can return valid symbols with zero value.
 

Static Public Member Functions

static void registerEHFramesInProcess (uint8_t *Addr, size_t Size)
 Register EH frames in the current process.
 
static void deregisterEHFramesInProcess (uint8_t *Addr, size_t Size)
 Deregister EH frames in the current process.
 
static uint64_t getSymbolAddressInProcess (const std::string &Name)
 This method returns the address of the specified function or variable in the current process.
 

Protected Types

typedef std::vector< EHFrameEHFrameInfos
 

Protected Attributes

EHFrameInfos EHFrames
 

Additional Inherited Members

- Public Types inherited from llvm::JITSymbolResolver
using LookupSet = std::set< StringRef >
 
using LookupResult = std::map< StringRef, JITEvaluatedSymbol >
 
using OnResolvedFunction = unique_function< void(Expected< LookupResult >)>
 

Detailed Description

Definition at line 60 of file RTDyldMemoryManager.h.

Member Typedef Documentation

◆ EHFrameInfos

typedef std::vector<EHFrame> llvm::RTDyldMemoryManager::EHFrameInfos
protected

Definition at line 145 of file RTDyldMemoryManager.h.

Constructor & Destructor Documentation

◆ RTDyldMemoryManager() [1/2]

llvm::RTDyldMemoryManager::RTDyldMemoryManager ( )
default

◆ RTDyldMemoryManager() [2/2]

llvm::RTDyldMemoryManager::RTDyldMemoryManager ( const RTDyldMemoryManager )
delete

◆ ~RTDyldMemoryManager()

llvm::RTDyldMemoryManager::~RTDyldMemoryManager ( )
overridedefault

Member Function Documentation

◆ deregisterEHFrames()

void llvm::RTDyldMemoryManager::deregisterEHFrames ( )
overridevirtual

◆ deregisterEHFramesInProcess()

void llvm::RTDyldMemoryManager::deregisterEHFramesInProcess ( uint8_t *  Addr,
size_t  Size 
)
static

Deregister EH frames in the current process.

Definition at line 122 of file RTDyldMemoryManager.cpp.

References llvm::__deregister_frame(), and Addr.

Referenced by deregisterEHFrames().

◆ findSymbol()

JITSymbol llvm::RTDyldMemoryManager::findSymbol ( const std::string &  Name)
inlineoverridevirtual

This method returns a RuntimeDyld::SymbolInfo for the specified function or variable.

It is used to resolve symbols during module linking.

By default this falls back on the legacy lookup method: 'getSymbolAddress'. The address returned by getSymbolAddress is treated as a strong, exported symbol, consistent with historical treatment by RuntimeDyld.

Clients writing custom RTDyldMemoryManagers are encouraged to override this method and return a SymbolInfo with the flags set correctly. This is necessary for RuntimeDyld to correctly handle weak and non-exported symbols.

Implements llvm::LegacyJITSymbolResolver.

Definition at line 100 of file RTDyldMemoryManager.h.

References llvm::JITSymbolFlags::Exported, getSymbolAddress(), and Name.

◆ findSymbolInLogicalDylib()

JITSymbol llvm::RTDyldMemoryManager::findSymbolInLogicalDylib ( const std::string &  Name)
inlineoverridevirtual

Default to treating all modules as separate.

By default this falls back on the legacy lookup method: 'getSymbolAddressInLogicalDylib'. The address returned by getSymbolAddressInLogicalDylib is treated as a strong, exported symbol, consistent with historical treatment by RuntimeDyld.

Clients writing custom RTDyldMemoryManagers are encouraged to override this method and return a SymbolInfo with the flags set correctly. This is necessary for RuntimeDyld to correctly handle weak and non-exported symbols.

Implements llvm::LegacyJITSymbolResolver.

Definition at line 123 of file RTDyldMemoryManager.h.

References llvm::JITSymbolFlags::Exported, getSymbolAddressInLogicalDylib(), and Name.

◆ getPointerToNamedFunction()

void * llvm::RTDyldMemoryManager::getPointerToNamedFunction ( const std::string &  Name,
bool  AbortOnFailure = true 
)
virtual

This method returns the address of the specified function.

As such it is only useful for resolving library symbols, not code generated symbols.

If AbortOnFailure is false and no function with the given name is found, this function returns a null pointer. Otherwise, it prints a message to stderr and aborts.

This function is deprecated for memory managers to be used with MCJIT or RuntimeDyld. Use getSymbolAddress instead.

Definition at line 282 of file RTDyldMemoryManager.cpp.

References Addr, getSymbolAddress(), Name, and llvm::report_fatal_error().

◆ getSymbolAddress()

virtual uint64_t llvm::RTDyldMemoryManager::getSymbolAddress ( const std::string &  Name)
inlinevirtual

Legacy symbol lookup - DEPRECATED! Please override findSymbol instead.

This method returns the address of the specified function or variable. It is used to resolve symbols during module linking.

Definition at line 85 of file RTDyldMemoryManager.h.

References getSymbolAddressInProcess(), and Name.

Referenced by findSymbol(), and getPointerToNamedFunction().

◆ getSymbolAddressInLogicalDylib()

virtual uint64_t llvm::RTDyldMemoryManager::getSymbolAddressInLogicalDylib ( const std::string &  Name)
inlinevirtual

Legacy symbol lookup – DEPRECATED! Please override findSymbolInLogicalDylib instead.

Default to treating all modules as separate.

Definition at line 108 of file RTDyldMemoryManager.h.

Referenced by findSymbolInLogicalDylib().

◆ getSymbolAddressInProcess()

uint64_t llvm::RTDyldMemoryManager::getSymbolAddressInProcess ( const std::string &  Name)
static

This method returns the address of the specified function or variable in the current process.

Definition at line 221 of file RTDyldMemoryManager.cpp.

References llvm::jit_noop(), Name, and llvm::sys::DynamicLibrary::SearchForAddressOfSymbol().

Referenced by getSymbolAddress().

◆ operator=()

void llvm::RTDyldMemoryManager::operator= ( const RTDyldMemoryManager )
delete

◆ registerEHFrames()

void llvm::RTDyldMemoryManager::registerEHFrames ( uint8_t *  Addr,
uint64_t  LoadAddr,
size_t  Size 
)
overridevirtual

Register the EH frames with the runtime so that c++ exceptions work.

Addr parameter provides the local address of the EH frame section data, while LoadAddr provides the address of the data in the target address space. If the section has not been remapped (which will usually be the case for local execution) these two values will be the same.

Implements llvm::RuntimeDyld::MemoryManager.

Definition at line 129 of file RTDyldMemoryManager.cpp.

References Addr, EHFrames, registerEHFramesInProcess(), and Size.

◆ registerEHFramesInProcess()

void llvm::RTDyldMemoryManager::registerEHFramesInProcess ( uint8_t *  Addr,
size_t  Size 
)
static

Register EH frames in the current process.

Definition at line 112 of file RTDyldMemoryManager.cpp.

References llvm::__register_frame(), and Addr.

Referenced by registerEHFrames().

Member Data Documentation

◆ EHFrames

EHFrameInfos llvm::RTDyldMemoryManager::EHFrames
protected

Definition at line 146 of file RTDyldMemoryManager.h.

Referenced by deregisterEHFrames(), and registerEHFrames().


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