class SectionMemoryManager

Declaration

class SectionMemoryManager : public RTDyldMemoryManager { /* full declaration omitted */ };

Description

This is a simple memory manager which implements the methods called by the RuntimeDyld class to allocate memory for section-based loading of objects, usually those generated by the MCJIT execution engine. This memory manager allocates all section memory as read-write. The RuntimeDyld will copy JITed section memory into these allocated blocks and perform any necessary linking and relocations. Any client using this memory manager MUST ensure that section-specific page permissions have been applied before attempting to execute functions in the JITed object. Permissions can be applied either by calling MCJIT::finalizeObject or by calling SectionMemoryManager::finalizeMemory directly. Clients of MCJIT should call MCJIT::finalizeObject.

Declared at: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h:39

Inherits from: RTDyldMemoryManager

Member Variables

private llvm::SectionMemoryManager::MemoryGroup CodeMem
private llvm::SectionMemoryManager::MemoryGroup RWDataMem
private llvm::SectionMemoryManager::MemoryGroup RODataMem
private llvm::SectionMemoryManager::MemoryMapper& MMapper

Inherited from RTDyldMemoryManager:

protected EHFrames

Method Overview

Inherited from RTDyldMemoryManager:

Inherited from LegacyJITSymbolResolver:

Inherited from JITSymbolResolver:

Inherited from MCJITMemoryManager:

Inherited from RuntimeDyld::MemoryManager:

Methods

SectionMemoryManager(
    llvm::SectionMemoryManager::MemoryMapper* MM =
        nullptr)

Description

Creates a SectionMemoryManager instance with \p MM as the associated memory mapper. If \p MM is nullptr then a default memory mapper is used that directly calls into the operating system.

Declared at: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h:107

Parameters

llvm::SectionMemoryManager::MemoryMapper* MM = nullptr

SectionMemoryManager(
    const llvm::SectionMemoryManager&)

Declared at: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h:108

Parameters

const llvm::SectionMemoryManager&

uint8_t* allocateCodeSection(
    uintptr_t Size,
    unsigned int Alignment,
    unsigned int SectionID,
    llvm::StringRef SectionName)

Description

Allocates a memory block of (at least) the given size suitable for executable code. The value of \p Alignment must be a power of two. If \p Alignment is zero a default alignment of 16 will be used.

Declared at: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h:117

Parameters

uintptr_t Size
unsigned int Alignment
unsigned int SectionID
llvm::StringRef SectionName

uint8_t* allocateDataSection(
    uintptr_t Size,
    unsigned int Alignment,
    unsigned int SectionID,
    llvm::StringRef SectionName,
    bool isReadOnly)

Description

Allocates a memory block of (at least) the given size suitable for executable code. The value of \p Alignment must be a power of two. If \p Alignment is zero a default alignment of 16 will be used.

Declared at: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h:126

Parameters

uintptr_t Size
unsigned int Alignment
unsigned int SectionID
llvm::StringRef SectionName
bool isReadOnly

uint8_t* allocateSection(
    llvm::SectionMemoryManager::AllocationPurpose
        Purpose,
    uintptr_t Size,
    unsigned int Alignment)

Declared at: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h:177

Parameters

llvm::SectionMemoryManager::AllocationPurpose Purpose
uintptr_t Size
unsigned int Alignment

void anchor()

Declared at: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h:183

std::error_code applyMemoryGroupPermissions(
    llvm::SectionMemoryManager::MemoryGroup&
        MemGroup,
    unsigned int Permissions)

Declared at: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h:180

Parameters

llvm::SectionMemoryManager::MemoryGroup& MemGroup
unsigned int Permissions

bool finalizeMemory(std::string* ErrMsg = nullptr)

Description

Update section-specific memory permissions and other attributes. 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.

Declared at: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h:141

Parameters

std::string* ErrMsg = nullptr

Returns

true if an error occurred, false otherwise.

virtual void invalidateInstructionCache()

Description

Invalidate instruction cache for code sections. Some platforms with separate data cache and instruction cache require explicit cache flush, otherwise JIT code manipulations (like resolved relocations) will get to the data cache but not to the instruction cache. This method is called from finalizeMemory.

Declared at: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h:150

~SectionMemoryManager()

Declared at: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h:110