LLVM 19.0.0git
Classes | Public Member Functions | Friends | List of all members
llvm::RuntimeDyld::MemoryManager Class Referenceabstract

Memory Management. More...

#include "llvm/ExecutionEngine/RuntimeDyld.h"

Inheritance diagram for llvm::RuntimeDyld::MemoryManager:
Inheritance graph
[legend]

Classes

struct  TLSSection
 An allocated TLS section. More...
 

Public Member Functions

 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.
 

Friends

class RuntimeDyld
 

Detailed Description

Memory Management.

Definition at line 92 of file RuntimeDyld.h.

Constructor & Destructor Documentation

◆ MemoryManager()

llvm::RuntimeDyld::MemoryManager::MemoryManager ( )
default

◆ ~MemoryManager()

virtual llvm::RuntimeDyld::MemoryManager::~MemoryManager ( )
virtualdefault

Member Function Documentation

◆ allocateCodeSection()

virtual uint8_t * llvm::RuntimeDyld::MemoryManager::allocateCodeSection ( uintptr_t  Size,
unsigned  Alignment,
unsigned  SectionID,
StringRef  SectionName 
)
pure virtual

Allocate a memory block of (at least) the given size suitable for executable code.

The SectionID is a unique identifier assigned by the RuntimeDyld instance, and optionally recorded by the memory manager to access a loaded section.

Implemented in llvm::orc::EPCGenericRTDyldMemoryManager, and llvm::SectionMemoryManager.

Referenced by llvm::RuntimeDyldELF::finalizeLoad(), and LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks().

◆ allocateDataSection()

virtual uint8_t * llvm::RuntimeDyld::MemoryManager::allocateDataSection ( uintptr_t  Size,
unsigned  Alignment,
unsigned  SectionID,
StringRef  SectionName,
bool  IsReadOnly 
)
pure virtual

Allocate a memory block of (at least) the given size suitable for data.

The SectionID is a unique identifier assigned by the JIT engine, and optionally recorded by the memory manager to access a loaded section.

Implemented in llvm::orc::EPCGenericRTDyldMemoryManager, and llvm::SectionMemoryManager.

Referenced by llvm::RuntimeDyldELF::finalizeLoad(), and LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks().

◆ allocateTLSSection()

RuntimeDyld::MemoryManager::TLSSection llvm::RuntimeDyld::MemoryManager::allocateTLSSection ( uintptr_t  Size,
unsigned  Alignment,
unsigned  SectionID,
StringRef  SectionName 
)
virtual

Allocate a memory block of (at least) the given size to be used for thread-local storage (TLS).

Definition at line 1284 of file RuntimeDyld.cpp.

References llvm::report_fatal_error().

◆ allowStubAllocation()

virtual bool llvm::RuntimeDyld::MemoryManager::allowStubAllocation ( ) const
inlinevirtual

Override to return false to tell LLVM no stub space will be needed.

This requires some guarantees depending on architecuture, but when you know what you are doing it saves allocated space.

Definition at line 148 of file RuntimeDyld.h.

Referenced by llvm::RuntimeDyldELF::processRelocationRef().

◆ deregisterEHFrames()

virtual void llvm::RuntimeDyld::MemoryManager::deregisterEHFrames ( )
pure virtual

◆ finalizeMemory()

virtual bool llvm::RuntimeDyld::MemoryManager::finalizeMemory ( std::string *  ErrMsg = nullptr)
pure virtual

This method is called when object loading is complete and section page permissions can be applied.

It is up to the memory manager implementation to decide whether or not to act on this method. The memory manager will typically allocate all sections as read-write and then apply specific permissions when this method is called. Code sections cannot be executed until this function has been called. In addition, any cache coherency operations needed to reliably use the memory are also performed.

Returns true if an error occurred, false otherwise.

Implemented in llvm::orc::EPCGenericRTDyldMemoryManager, and llvm::SectionMemoryManager.

Referenced by llvm::RuntimeDyld::finalizeWithMemoryManagerLocking(), and LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks().

◆ needsToReserveAllocationSpace()

virtual bool llvm::RuntimeDyld::MemoryManager::needsToReserveAllocationSpace ( )
inlinevirtual

Override to return true to enable the reserveAllocationSpace callback.

Reimplemented in llvm::orc::EPCGenericRTDyldMemoryManager.

Definition at line 143 of file RuntimeDyld.h.

◆ notifyObjectLoaded()

virtual void llvm::RuntimeDyld::MemoryManager::notifyObjectLoaded ( RuntimeDyld RTDyld,
const object::ObjectFile Obj 
)
inlinevirtual

This method is called after an object has been loaded into memory but before relocations are applied to the loaded sections.

Memory managers which are preparing code for execution in an external address space can use this call to remap the section addresses for the newly loaded object.

For clients that do not need access to an ExecutionEngine instance this method should be preferred to its cousin MCJITMemoryManager::notifyObjectLoaded as this method is compatible with ORC JIT stacks.

Reimplemented in llvm::orc::EPCGenericRTDyldMemoryManager.

Definition at line 182 of file RuntimeDyld.h.

Referenced by llvm::RuntimeDyld::loadObject().

◆ registerEHFrames()

virtual void llvm::RuntimeDyld::MemoryManager::registerEHFrames ( uint8_t *  Addr,
uint64_t  LoadAddr,
size_t  Size 
)
pure virtual

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.

Implemented in llvm::orc::EPCGenericRTDyldMemoryManager, and llvm::RTDyldMemoryManager.

Referenced by llvm::RuntimeDyldELF::registerEHFrames(), and llvm::RuntimeDyldCOFFX86_64::registerEHFrames().

◆ reserveAllocationSpace()

virtual void llvm::RuntimeDyld::MemoryManager::reserveAllocationSpace ( uintptr_t  CodeSize,
Align  CodeAlign,
uintptr_t  RODataSize,
Align  RODataAlign,
uintptr_t  RWDataSize,
Align  RWDataAlign 
)
inlinevirtual

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.

Note that by default the callback is disabled. To enable it redefine the method needsToReserveAllocationSpace to return true.

Reimplemented in llvm::orc::EPCGenericRTDyldMemoryManager.

Definition at line 137 of file RuntimeDyld.h.

Friends And Related Function Documentation

◆ RuntimeDyld

friend class RuntimeDyld
friend

Definition at line 93 of file RuntimeDyld.h.


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