class RuntimeDyldImpl

Declaration

class RuntimeDyldImpl { /* full declaration omitted */ };

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:238

Member Variables

protected RuntimeDyld::MemoryManager& MemMgr
protected llvm::JITSymbolResolver& Resolver
protected llvm::RuntimeDyldImpl::SectionList Sections
protected llvm::RTDyldSymbolTable GlobalSymbolTable
protected std::unordered_map<unsigned int, RelocationList> Relocations
protected StringMap<llvm::RuntimeDyldImpl::RelocationList> ExternalSymbolRelocations
protected Triple::ArchType Arch
protected bool IsTargetLittleEndian
protected bool IsMipsO32ABI
protected bool IsMipsN32ABI
protected bool IsMipsN64ABI
protected bool ProcessAllSections
protected sys::Mutex lock
protected llvm::RuntimeDyldImpl::NotifyStubEmittedFunction NotifyStubEmitted
protected bool HasError
protected std::string ErrorStr
protected static const unsigned int AbsoluteSymbolSection = ~0U

Method Overview

  • public RuntimeDyldImpl(RuntimeDyld::MemoryManager & MemMgr, llvm::JITSymbolResolver & Resolver)
  • protected void addRelocationForSection(const llvm::RelocationEntry & RE, unsigned int SectionID)
  • protected void addRelocationForSymbol(const llvm::RelocationEntry & RE, llvm::StringRef SymbolName)
  • protected void applyExternalSymbolRelocations(const StringMap<llvm::JITEvaluatedSymbol> ExternalSymbolMap)
  • public void clearError()
  • protected unsigned int computeGOTSize(const llvm::object::ObjectFile & Obj)
  • protected unsigned int computeSectionStubBufSize(const llvm::object::ObjectFile & Obj, const llvm::object::SectionRef & Section)
  • protected llvm::Error computeTotalAllocSize(const llvm::object::ObjectFile & Obj, uint64_t & CodeSize, uint32_t & CodeAlign, uint64_t & RODataSize, uint32_t & RODataAlign, uint64_t & RWDataSize, uint32_t & RWDataAlign)
  • protected uint8_t * createStubFunction(uint8_t * Addr, unsigned int AbiVariant = 0)
  • public void deregisterEHFrames()
  • protected llvm::Error emitCommonSymbols(const llvm::object::ObjectFile & Obj, llvm::RuntimeDyldImpl::CommonSymbolList & CommonSymbols, uint64_t CommonSize, uint32_t CommonAlign)
  • protected Expected<unsigned int> emitSection(const llvm::object::ObjectFile & Obj, const llvm::object::SectionRef & Section, bool IsCode)
  • public static void finalizeAsync(std::unique_ptr<RuntimeDyldImpl> This, unique_function<void (object::OwningBinary<object::ObjectFile>, std::unique_ptr<RuntimeDyld::LoadedObjectInfo>, llvm::Error)> OnEmitted, object::OwningBinary<object::ObjectFile> O, std::unique_ptr<RuntimeDyld::LoadedObjectInfo> Info)
  • public virtual llvm::Error finalizeLoad(const llvm::object::ObjectFile & ObjImg, llvm::RuntimeDyldImpl::ObjSectionToIDMap & SectionMap)
  • protected Expected<unsigned int> findOrEmitSection(const llvm::object::ObjectFile & Obj, const llvm::object::SectionRef & Section, bool IsCode, llvm::RuntimeDyldImpl::ObjSectionToIDMap & LocalSections)
  • public llvm::StringRef getErrorString()
  • protected virtual size_t getGOTEntrySize()
  • protected virtual Expected<llvm::JITSymbolFlags> getJITSymbolFlags(const llvm::object::SymbolRef & Sym)
  • protected virtual unsigned int getMaxStubSize() const
  • public uint8_t * getSectionAddress(unsigned int SectionID) const
  • public llvm::StringRef getSectionContent(unsigned int SectionID) const
  • public uint64_t getSectionLoadAddress(unsigned int SectionID) const
  • protected virtual unsigned int getStubAlignment()
  • public llvm::JITEvaluatedSymbol getSymbol(llvm::StringRef Name) const
  • public uint8_t * getSymbolLocalAddress(llvm::StringRef Name) const
  • public unsigned int getSymbolSectionID(llvm::StringRef Name) const
  • public std::map<StringRef, JITEvaluatedSymbol> getSymbolTable() const
  • public bool hasError()
  • public virtual bool isCompatibleFile(const llvm::object::ObjectFile & Obj) const
  • public virtual std::unique_ptr<RuntimeDyld::LoadedObjectInfo> loadObject(const object::ObjectFile & Obj)
  • protected Expected<llvm::RuntimeDyldImpl::ObjSectionToIDMap> loadObjectImpl(const object::ObjectFile & Obj)
  • public void mapSectionAddress(const void * LocalAddress, uint64_t TargetAddress)
  • protected virtual uint64_t modifyAddressBasedOnFlags(uint64_t Addr, llvm::JITSymbolFlags Flags) const
  • protected virtual Expected<llvm::object::relocation_iterator> processRelocationRef(unsigned int SectionID, llvm::object::relocation_iterator RelI, const llvm::object::ObjectFile & Obj, llvm::RuntimeDyldImpl::ObjSectionToIDMap & ObjSectionToID, llvm::RuntimeDyldImpl::StubMap & Stubs)
  • protected uint64_t readBytesUnaligned(uint8_t * Src, unsigned int Size) const
  • public void reassignSectionAddress(unsigned int SectionID, uint64_t Addr)
  • public virtual void registerEHFrames()
  • protected virtual bool relocationNeedsGot(const llvm::object::RelocationRef & R) const
  • protected virtual bool relocationNeedsStub(const llvm::object::RelocationRef & R) const
  • protected llvm::Error resolveExternalSymbols()
  • public void resolveLocalRelocations()
  • protected virtual void resolveRelocation(const llvm::RelocationEntry & RE, uint64_t Value)
  • protected void resolveRelocationList(const llvm::RuntimeDyldImpl::RelocationList & Relocs, uint64_t Value)
  • public void resolveRelocations()
  • protected virtual void setMipsABI(const llvm::object::ObjectFile & Obj)
  • public void setNotifyStubEmitted(llvm::RuntimeDyldImpl::NotifyStubEmittedFunction NotifyStubEmitted)
  • public void setProcessAllSections(bool ProcessAllSections)
  • protected void writeBytesUnaligned(uint64_t Value, uint8_t * Dst, unsigned int Size) const
  • protected void writeInt16BE(uint8_t * Addr, uint16_t Value)
  • protected void writeInt32BE(uint8_t * Addr, uint32_t Value)
  • protected void writeInt64BE(uint8_t * Addr, uint64_t Value)
  • public virtual ~RuntimeDyldImpl()

Methods

RuntimeDyldImpl(
    RuntimeDyld::MemoryManager& MemMgr,
    llvm::JITSymbolResolver& Resolver)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:449

Parameters

RuntimeDyld::MemoryManager& MemMgr
llvm::JITSymbolResolver& Resolver

void addRelocationForSection(
    const llvm::RelocationEntry& RE,
    unsigned int SectionID)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:385

Parameters

const llvm::RelocationEntry& RE
unsigned int SectionID

void addRelocationForSymbol(
    const llvm::RelocationEntry& RE,
    llvm::StringRef SymbolName)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:389

Parameters

const llvm::RelocationEntry& RE
llvm::StringRef SymbolName

void applyExternalSymbolRelocations(
    const StringMap<llvm::JITEvaluatedSymbol>
        ExternalSymbolMap)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:412

Parameters

const StringMap<llvm::JITEvaluatedSymbol> ExternalSymbolMap

void clearError()

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:561

unsigned int computeGOTSize(
    const llvm::object::ObjectFile& Obj)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:426

Parameters

const llvm::object::ObjectFile& Obj

unsigned int computeSectionStubBufSize(
    const llvm::object::ObjectFile& Obj,
    const llvm::object::SectionRef& Section)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:429

Parameters

const llvm::object::ObjectFile& Obj
const llvm::object::SectionRef& Section

llvm::Error computeTotalAllocSize(
    const llvm::object::ObjectFile& Obj,
    uint64_t& CodeSize,
    uint32_t& CodeAlign,
    uint64_t& RODataSize,
    uint32_t& RODataAlign,
    uint64_t& RWDataSize,
    uint32_t& RWDataAlign)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:420

Parameters

const llvm::object::ObjectFile& Obj
uint64_t& CodeSize
uint32_t& CodeAlign
uint64_t& RODataSize
uint32_t& RODataAlign
uint64_t& RWDataSize
uint32_t& RWDataAlign

uint8_t* createStubFunction(
    uint8_t* Addr,
    unsigned int AbiVariant = 0)

Description

Emits long jump instruction to Addr.

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:393

Parameters

uint8_t* Addr
unsigned int AbiVariant = 0

Returns

Pointer to the memory area for emitting target address.

void deregisterEHFrames()

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:574

llvm::Error emitCommonSymbols(
    const llvm::object::ObjectFile& Obj,
    llvm::RuntimeDyldImpl::CommonSymbolList&
        CommonSymbols,
    uint64_t CommonSize,
    uint32_t CommonAlign)

Description

Given the common symbols discovered in the object file, emit a new section for them and update the symbol mappings in the object and symbol table.

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:363

Parameters

const llvm::object::ObjectFile& Obj
llvm::RuntimeDyldImpl::CommonSymbolList& CommonSymbols
uint64_t CommonSize
uint32_t CommonAlign

Expected<unsigned int> emitSection(
    const llvm::object::ObjectFile& Obj,
    const llvm::object::SectionRef& Section,
    bool IsCode)

Description

Emits section data from the object file to the MemoryManager.

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:371

Parameters

const llvm::object::ObjectFile& Obj
const llvm::object::SectionRef& Section
bool IsCode
if it's true then allocateCodeSection() will be used for emits, else allocateDataSection() will be used.

Returns

SectionID.

static void finalizeAsync(
    std::unique_ptr<RuntimeDyldImpl> This,
    unique_function<void(
        object::OwningBinary<object::ObjectFile>,
        std::unique_ptr<
            RuntimeDyld::LoadedObjectInfo>,
        llvm::Error)> OnEmitted,
    object::OwningBinary<object::ObjectFile> O,
    std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
        Info)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:544

Parameters

std::unique_ptr<RuntimeDyldImpl> This
unique_function<void( object::OwningBinary<object::ObjectFile>, std::unique_ptr< RuntimeDyld::LoadedObjectInfo>, llvm::Error)> OnEmitted
object::OwningBinary<object::ObjectFile> O
std::unique_ptr<RuntimeDyld::LoadedObjectInfo> Info

virtual llvm::Error finalizeLoad(
    const llvm::object::ObjectFile& ObjImg,
    llvm::RuntimeDyldImpl::ObjSectionToIDMap&
        SectionMap)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:576

Parameters

const llvm::object::ObjectFile& ObjImg
llvm::RuntimeDyldImpl::ObjSectionToIDMap& SectionMap

Expected<unsigned int> findOrEmitSection(
    const llvm::object::ObjectFile& Obj,
    const llvm::object::SectionRef& Section,
    bool IsCode,
    llvm::RuntimeDyldImpl::ObjSectionToIDMap&
        LocalSections)

Description

Find Section in LocalSections. If the secton is not found - emit it and store in LocalSections.

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:380

Parameters

const llvm::object::ObjectFile& Obj
const llvm::object::SectionRef& Section
bool IsCode
if it's true then allocateCodeSection() will be used for emmits, else allocateDataSection() will be used.
llvm::RuntimeDyldImpl::ObjSectionToIDMap& LocalSections

Returns

SectionID.

llvm::StringRef getErrorString()

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:564

virtual size_t getGOTEntrySize()

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:436

virtual Expected<llvm::JITSymbolFlags>
getJITSymbolFlags(
    const llvm::object::SymbolRef& Sym)

Description

Generate JITSymbolFlags from a libObject symbol.

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:349

Parameters

const llvm::object::SymbolRef& Sym

virtual unsigned int getMaxStubSize() const

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:314

uint8_t* getSectionAddress(
    unsigned int SectionID) const

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:471

Parameters

unsigned int SectionID

llvm::StringRef getSectionContent(
    unsigned int SectionID) const

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:478

Parameters

unsigned int SectionID

uint64_t getSectionLoadAddress(
    unsigned int SectionID) const

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:464

Parameters

unsigned int SectionID

virtual unsigned int getStubAlignment()

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:315

llvm::JITEvaluatedSymbol getSymbol(
    llvm::StringRef Name) const

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:507

Parameters

llvm::StringRef Name

uint8_t* getSymbolLocalAddress(
    llvm::StringRef Name) const

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:487

Parameters

llvm::StringRef Name

unsigned int getSymbolSectionID(
    llvm::StringRef Name) const

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:500

Parameters

llvm::StringRef Name

std::map<StringRef, JITEvaluatedSymbol>
getSymbolTable() const

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:527

bool hasError()

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:558

virtual bool isCompatibleFile(
    const llvm::object::ObjectFile& Obj) const

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:566

Parameters

const llvm::object::ObjectFile& Obj

virtual std::unique_ptr<
    RuntimeDyld::LoadedObjectInfo>
loadObject(const object::ObjectFile& Obj)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:462

Parameters

const object::ObjectFile& Obj

Expected<llvm::RuntimeDyldImpl::ObjSectionToIDMap>
loadObjectImpl(const object::ObjectFile& Obj)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:433

Parameters

const object::ObjectFile& Obj

void mapSectionAddress(const void* LocalAddress,
                       uint64_t TargetAddress)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:555

Parameters

const void* LocalAddress
uint64_t TargetAddress

virtual uint64_t modifyAddressBasedOnFlags(
    uint64_t Addr,
    llvm::JITSymbolFlags Flags) const

Description

Modify the given target address based on the given symbol flags. This can be used by subclasses to tweak addresses based on symbol flags, For example: the MachO/ARM target uses it to set the low bit if the target is a thumb symbol.

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:355

Parameters

uint64_t Addr
llvm::JITSymbolFlags Flags

virtual Expected<
    llvm::object::relocation_iterator>
processRelocationRef(
    unsigned int SectionID,
    llvm::object::relocation_iterator RelI,
    const llvm::object::ObjectFile& Obj,
    llvm::RuntimeDyldImpl::ObjSectionToIDMap&
        ObjSectionToID,
    llvm::RuntimeDyldImpl::StubMap& Stubs)

Description

Parses one or more object file relocations (some object files use relocation pairs) and stores it to Relocations or SymbolRelocations (this depends on the object file type).

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:408

Parameters

unsigned int SectionID
llvm::object::relocation_iterator RelI
const llvm::object::ObjectFile& Obj
llvm::RuntimeDyldImpl::ObjSectionToIDMap& ObjSectionToID
llvm::RuntimeDyldImpl::StubMap& Stubs

Returns

Iterator to the next relocation that needs to be parsed.

uint64_t readBytesUnaligned(
    uint8_t* Src,
    unsigned int Size) const

Description

Endian-aware read Read the least significant Size bytes from Src.

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:342

Parameters

uint8_t* Src
unsigned int Size

void reassignSectionAddress(
    unsigned int SectionID,
    uint64_t Addr)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:553

Parameters

unsigned int SectionID
uint64_t Addr

virtual void registerEHFrames()

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:572

virtual bool relocationNeedsGot(
    const llvm::object::RelocationRef& R) const

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:439

Parameters

const llvm::object::RelocationRef& R

virtual bool relocationNeedsStub(
    const llvm::object::RelocationRef& R) const

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:444

Parameters

const llvm::object::RelocationRef& R

llvm::Error resolveExternalSymbols()

Description

Resolve relocations to external symbols.

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:416

void resolveLocalRelocations()

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:542

virtual void resolveRelocation(
    const llvm::RelocationEntry& RE,
    uint64_t Value)

Description

A object file specific relocation resolver

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:401

Parameters

const llvm::RelocationEntry& RE
The relocation to be resolved
uint64_t Value
Target symbol address to apply the relocation action

void resolveRelocationList(
    const llvm::RuntimeDyldImpl::RelocationList&
        Relocs,
    uint64_t Value)

Description

Resolves relocations from Relocs list with address from Value.

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:396

Parameters

const llvm::RuntimeDyldImpl::RelocationList& Relocs
uint64_t Value

void resolveRelocations()

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:540

virtual void setMipsABI(
    const llvm::object::ObjectFile& Obj)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:335

Parameters

const llvm::object::ObjectFile& Obj

void setNotifyStubEmitted(
    llvm::RuntimeDyldImpl::
        NotifyStubEmittedFunction
            NotifyStubEmitted)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:568

Parameters

llvm::RuntimeDyldImpl::NotifyStubEmittedFunction NotifyStubEmitted

void setProcessAllSections(
    bool ProcessAllSections)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:457

Parameters

bool ProcessAllSections

void writeBytesUnaligned(uint64_t Value,
                         uint8_t* Dst,
                         unsigned int Size) const

Description

Endian-aware write. Write the least significant Size bytes from Value to Dst.

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:346

Parameters

uint64_t Value
uint8_t* Dst
unsigned int Size

void writeInt16BE(uint8_t* Addr, uint16_t Value)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:320

Parameters

uint8_t* Addr
uint16_t Value

void writeInt32BE(uint8_t* Addr, uint32_t Value)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:325

Parameters

uint8_t* Addr
uint32_t Value

void writeInt64BE(uint8_t* Addr, uint64_t Value)

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:330

Parameters

uint8_t* Addr
uint64_t Value

virtual ~RuntimeDyldImpl()

Declared at: llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h:455