LLVM API Documentation

Public Member Functions | Static Public Member Functions
llvm::RTDyldMemoryManager Class Reference

#include <RTDyldMemoryManager.h>

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

List of all members.

Public Member Functions

 RTDyldMemoryManager ()
virtual ~RTDyldMemoryManager ()
virtual uint8_t * allocateCodeSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName)=0
virtual uint8_t * allocateDataSection (uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, bool IsReadOnly)=0
virtual void reserveAllocationSpace (uintptr_t CodeSize, uintptr_t DataSizeRO, uintptr_t DataSizeRW)
virtual bool needsToReserveAllocationSpace ()
 Override to return true to enable the reserveAllocationSpace callback.
virtual void registerEHFrames (uint8_t *Addr, uint64_t LoadAddr, size_t Size)
virtual void deregisterEHFrames (uint8_t *Addr, uint64_t LoadAddr, size_t Size)
virtual uint64_t getSymbolAddress (const std::string &Name)
virtual void * getPointerToNamedFunction (const std::string &Name, bool AbortOnFailure=true)
virtual void notifyObjectLoaded (ExecutionEngine *EE, const object::ObjectFile &)
virtual bool finalizeMemory (std::string *ErrMsg=nullptr)=0

Static Public Member Functions

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

Detailed Description

Definition at line 36 of file RTDyldMemoryManager.h.


Constructor & Destructor Documentation

llvm::RTDyldMemoryManager::RTDyldMemoryManager ( ) [inline]

Definition at line 40 of file RTDyldMemoryManager.h.

Definition at line 32 of file RTDyldMemoryManager.cpp.


Member Function Documentation

virtual uint8_t* llvm::RTDyldMemoryManager::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 JIT engine, and optionally recorded by the memory manager to access a loaded section.

Implemented in llvm::SectionMemoryManager, and llvm::LinkingMemoryManager.

virtual uint8_t* llvm::RTDyldMemoryManager::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::SectionMemoryManager, and llvm::LinkingMemoryManager.

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

void llvm::RTDyldMemoryManager::deregisterEHFrames ( uint8_t *  Addr,
uint64_t  LoadAddr,
size_t  Size 
) [virtual]
virtual bool llvm::RTDyldMemoryManager::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::LinkingMemoryManager, and llvm::SectionMemoryManager.

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 272 of file RTDyldMemoryManager.cpp.

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

Referenced by llvm::MCJIT::getPointerToNamedFunction().

virtual uint64_t llvm::RTDyldMemoryManager::getSymbolAddress ( const std::string &  Name) [inline, virtual]

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

Reimplemented in llvm::LinkingMemoryManager.

Definition at line 88 of file RTDyldMemoryManager.h.

References getSymbolAddressInProcess().

Referenced by getPointerToNamedFunction().

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 214 of file RTDyldMemoryManager.cpp.

References llvm::LibFunc::fstat, llvm::LibFunc::fstat64, llvm::jit_noop(), llvm::LibFunc::lstat, llvm::LibFunc::lstat64, llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(), llvm::LibFunc::stat, and llvm::LibFunc::stat64.

Referenced by getSymbolAddress().

Override to return true to enable the reserveAllocationSpace callback.

Reimplemented in llvm::LinkingMemoryManager.

Definition at line 70 of file RTDyldMemoryManager.h.

This method is called after an object has been loaded into memory but before relocations are applied to the loaded sections. The object load may have been initiated by MCJIT to resolve an external symbol for another object that is being finalized. In that case, the object about which the memory manager is being notified will be finalized immediately after the memory manager returns from this call.

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.

Reimplemented in llvm::LinkingMemoryManager.

Definition at line 114 of file RTDyldMemoryManager.h.

void llvm::RTDyldMemoryManager::registerEHFrames ( uint8_t *  Addr,
uint64_t  LoadAddr,
size_t  Size 
) [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.

Reimplemented in llvm::LinkingMemoryManager.

Definition at line 120 of file RTDyldMemoryManager.cpp.

References llvm::__register_frame().

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

virtual void llvm::RTDyldMemoryManager::reserveAllocationSpace ( uintptr_t  CodeSize,
uintptr_t  DataSizeRO,
uintptr_t  DataSizeRW 
) [inline, virtual]

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::LinkingMemoryManager.

Definition at line 66 of file RTDyldMemoryManager.h.


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