LLVM  6.0.0svn
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
llvm::RuntimeDyldImpl Class Referenceabstract

#include "ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h"

Inheritance diagram for llvm::RuntimeDyldImpl:
Inheritance graph
Collaboration diagram for llvm::RuntimeDyldImpl:
Collaboration graph

Public Member Functions

 RuntimeDyldImpl (RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
virtual ~RuntimeDyldImpl ()
void setProcessAllSections (bool ProcessAllSections)
void setRuntimeDyldChecker (RuntimeDyldCheckerImpl *Checker)
virtual std::unique_ptr< RuntimeDyld::LoadedObjectInfoloadObject (const object::ObjectFile &Obj)=0
uint8_t * getSymbolLocalAddress (StringRef Name) const
JITEvaluatedSymbol getSymbol (StringRef Name) const
void resolveRelocations ()
void reassignSectionAddress (unsigned SectionID, uint64_t Addr)
void mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress)
bool hasError ()
void clearError ()
StringRef getErrorString ()
virtual bool isCompatibleFile (const ObjectFile &Obj) const =0
virtual void registerEHFrames ()
void deregisterEHFrames ()
virtual Error finalizeLoad (const ObjectFile &ObjImg, ObjSectionToIDMap &SectionMap)

Protected Types

typedef SmallVector< SectionEntry, 64 > SectionList
typedef unsigned SID
typedef std::map< SectionRef, unsignedObjSectionToIDMap
typedef std::vector< SymbolRefCommonSymbolList
typedef SmallVector< RelocationEntry, 64 > RelocationList
typedef std::map< RelocationValueRef, uintptr_t > StubMap

Protected Member Functions

virtual unsigned getMaxStubSize ()=0
virtual unsigned getStubAlignment ()=0
uint64_t getSectionLoadAddress (unsigned SectionID) const
uint8_t * getSectionAddress (unsigned SectionID) const
void writeInt16BE (uint8_t *Addr, uint16_t Value)
void writeInt32BE (uint8_t *Addr, uint32_t Value)
void writeInt64BE (uint8_t *Addr, uint64_t Value)
virtual void setMipsABI (const ObjectFile &Obj)
uint64_t readBytesUnaligned (uint8_t *Src, unsigned Size) const
 Endian-aware read Read the least significant Size bytes from Src. More...
void writeBytesUnaligned (uint64_t Value, uint8_t *Dst, unsigned Size) const
 Endian-aware write. More...
virtual JITSymbolFlags getJITSymbolFlags (const BasicSymbolRef &Sym)
 Generate JITSymbolFlags from a libObject symbol. More...
virtual uint64_t modifyAddressBasedOnFlags (uint64_t Addr, JITSymbolFlags Flags) const
 Modify the given target address based on the given symbol flags. More...
Error emitCommonSymbols (const ObjectFile &Obj, CommonSymbolList &CommonSymbols)
 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. More...
Expected< unsignedemitSection (const ObjectFile &Obj, const SectionRef &Section, bool IsCode)
 Emits section data from the object file to the MemoryManager. More...
Expected< unsignedfindOrEmitSection (const ObjectFile &Obj, const SectionRef &Section, bool IsCode, ObjSectionToIDMap &LocalSections)
 Find Section in LocalSections. More...
void addRelocationForSection (const RelocationEntry &RE, unsigned SectionID)
void addRelocationForSymbol (const RelocationEntry &RE, StringRef SymbolName)
uint8_t * createStubFunction (uint8_t *Addr, unsigned AbiVariant=0)
 Emits long jump instruction to Addr. More...
void resolveRelocationList (const RelocationList &Relocs, uint64_t Value)
 Resolves relocations from Relocs list with address from Value. More...
virtual void resolveRelocation (const RelocationEntry &RE, uint64_t Value)=0
 A object file specific relocation resolver. More...
virtual Expected< relocation_iteratorprocessRelocationRef (unsigned SectionID, relocation_iterator RelI, const ObjectFile &Obj, ObjSectionToIDMap &ObjSectionToID, StubMap &Stubs)=0
 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). More...
Error resolveExternalSymbols ()
 Resolve relocations to external symbols. More...
Error computeTotalAllocSize (const ObjectFile &Obj, uint64_t &CodeSize, uint32_t &CodeAlign, uint64_t &RODataSize, uint32_t &RODataAlign, uint64_t &RWDataSize, uint32_t &RWDataAlign)
unsigned computeGOTSize (const ObjectFile &Obj)
unsigned computeSectionStubBufSize (const ObjectFile &Obj, const SectionRef &Section)
Expected< ObjSectionToIDMaploadObjectImpl (const object::ObjectFile &Obj)
virtual size_t getGOTEntrySize ()
virtual bool relocationNeedsGot (const RelocationRef &R) const
virtual bool relocationNeedsStub (const RelocationRef &R) const

Protected Attributes

SectionList Sections
RTDyldSymbolTable GlobalSymbolTable
std::unordered_map< unsigned, RelocationListRelocations
StringMap< RelocationListExternalSymbolRelocations
Triple::ArchType Arch
bool IsTargetLittleEndian
bool IsMipsO32ABI
bool IsMipsN32ABI
bool IsMipsN64ABI
bool ProcessAllSections
sys::Mutex lock
bool HasError
std::string ErrorStr

Static Protected Attributes

static const unsigned AbsoluteSymbolSection = ~0U


class RuntimeDyld::LoadedObjectInfo
class RuntimeDyldCheckerImpl

Detailed Description

Definition at line 242 of file RuntimeDyldImpl.h.

Member Typedef Documentation

◆ CommonSymbolList

typedef std::vector<SymbolRef> llvm::RuntimeDyldImpl::CommonSymbolList

Definition at line 273 of file RuntimeDyldImpl.h.

◆ ObjSectionToIDMap

Definition at line 267 of file RuntimeDyldImpl.h.

◆ RelocationList

Definition at line 280 of file RuntimeDyldImpl.h.

◆ SectionList

Definition at line 259 of file RuntimeDyldImpl.h.


Definition at line 262 of file RuntimeDyldImpl.h.

◆ StubMap

typedef std::map<RelocationValueRef, uintptr_t> llvm::RuntimeDyldImpl::StubMap

Definition at line 292 of file RuntimeDyldImpl.h.

Constructor & Destructor Documentation

◆ RuntimeDyldImpl()

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

Definition at line 469 of file RuntimeDyldImpl.h.

◆ ~RuntimeDyldImpl()

RuntimeDyldImpl::~RuntimeDyldImpl ( )

Definition at line 67 of file RuntimeDyld.cpp.

Member Function Documentation

◆ addRelocationForSection()

void llvm::RuntimeDyldImpl::addRelocationForSection ( const RelocationEntry RE,
unsigned  SectionID 

◆ addRelocationForSymbol()

void llvm::RuntimeDyldImpl::addRelocationForSymbol ( const RelocationEntry RE,
StringRef  SymbolName 

◆ clearError()

void llvm::RuntimeDyldImpl::clearError ( )

Definition at line 531 of file RuntimeDyldImpl.h.

◆ computeGOTSize()

unsigned llvm::RuntimeDyldImpl::computeGOTSize ( const ObjectFile Obj)

◆ computeSectionStubBufSize()

unsigned llvm::RuntimeDyldImpl::computeSectionStubBufSize ( const ObjectFile Obj,
const SectionRef Section 

◆ computeTotalAllocSize()

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

◆ createStubFunction()

uint8_t * llvm::RuntimeDyldImpl::createStubFunction ( uint8_t *  Addr,
unsigned  AbiVariant = 0 

◆ deregisterEHFrames()

void llvm::RuntimeDyldImpl::deregisterEHFrames ( )

Definition at line 76 of file RuntimeDyld.cpp.

◆ emitCommonSymbols()

Error llvm::RuntimeDyldImpl::emitCommonSymbols ( const ObjectFile Obj,
CommonSymbolList CommonSymbols 

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.

Definition at line 623 of file RuntimeDyld.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Align, llvm::alignTo(), llvm::dbgs(), DEBUG, llvm::format(), llvm::object::Binary::getFileName(), llvm::OffsetToAlignment(), llvm::report_fatal_error(), llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Size, and llvm::Error::success().

◆ emitSection()

Expected< unsigned > llvm::RuntimeDyldImpl::emitSection ( const ObjectFile Obj,
const SectionRef Section,
bool  IsCode 

◆ finalizeLoad()

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

◆ findOrEmitSection()

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

Find Section in LocalSections.

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

IsCodeif it's true then allocateCodeSection() will be used for emmits, else allocateDataSection() will be used.

Definition at line 821 of file RuntimeDyld.cpp.

References if(), and llvm::ARMBuildAttrs::Section.

Referenced by llvm::RuntimeDyldMachOX86_64::finalizeSection(), llvm::RuntimeDyldMachOI386::finalizeSection(), llvm::RuntimeDyldMachOARM::finalizeSection(), llvm::RuntimeDyldELF::loadObject(), llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), and llvm::RuntimeDyldELF::processRelocationRef().

◆ getErrorString()

StringRef llvm::RuntimeDyldImpl::getErrorString ( )

Definition at line 534 of file RuntimeDyldImpl.h.

◆ getGOTEntrySize()

virtual size_t llvm::RuntimeDyldImpl::getGOTEntrySize ( )

Reimplemented in llvm::RuntimeDyldELF.

Definition at line 456 of file RuntimeDyldImpl.h.

◆ getJITSymbolFlags()

JITSymbolFlags llvm::RuntimeDyldImpl::getJITSymbolFlags ( const BasicSymbolRef Sym)

Generate JITSymbolFlags from a libObject symbol.

Reimplemented in llvm::RuntimeDyldMachOARM.

Definition at line 619 of file RuntimeDyld.cpp.

References llvm::JITSymbolFlags::fromObjectSymbol().

Referenced by llvm::RuntimeDyldMachOARM::getJITSymbolFlags().

◆ getMaxStubSize()

virtual unsigned llvm::RuntimeDyldImpl::getMaxStubSize ( )
protectedpure virtual

◆ getSectionAddress()

uint8_t* llvm::RuntimeDyldImpl::getSectionAddress ( unsigned  SectionID) const

◆ getSectionLoadAddress()

uint64_t llvm::RuntimeDyldImpl::getSectionLoadAddress ( unsigned  SectionID) const

Definition at line 322 of file RuntimeDyldImpl.h.

Referenced by llvm::RuntimeDyldELFMips::resolveRelocation().

◆ getStubAlignment()

virtual unsigned llvm::RuntimeDyldImpl::getStubAlignment ( )
protectedpure virtual

◆ getSymbol()

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

◆ getSymbolLocalAddress()

uint8_t* llvm::RuntimeDyldImpl::getSymbolLocalAddress ( StringRef  Name) const

◆ hasError()

bool llvm::RuntimeDyldImpl::hasError ( )

Definition at line 528 of file RuntimeDyldImpl.h.

◆ isCompatibleFile()

virtual bool llvm::RuntimeDyldImpl::isCompatibleFile ( const ObjectFile Obj) const
pure virtual

◆ loadObject()

virtual std::unique_ptr<RuntimeDyld::LoadedObjectInfo> llvm::RuntimeDyldImpl::loadObject ( const object::ObjectFile Obj)
pure virtual

◆ loadObjectImpl()

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

◆ mapSectionAddress()

void llvm::RuntimeDyldImpl::mapSectionAddress ( const void *  LocalAddress,
uint64_t  TargetAddress 

Definition at line 157 of file RuntimeDyld.cpp.

References llvm_unreachable.

◆ modifyAddressBasedOnFlags()

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

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.

Reimplemented in llvm::RuntimeDyldMachOARM.

Definition at line 379 of file RuntimeDyldImpl.h.

References llvm::ARMBuildAttrs::Section, and llvm::AMDGPU::HSAMD::Kernel::Key::SymbolName.

◆ processRelocationRef()

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

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).

Iterator to the next relocation that needs to be parsed.

Implemented in llvm::RuntimeDyldMachOAArch64, llvm::RuntimeDyldELF, llvm::RuntimeDyldCOFFX86_64, llvm::RuntimeDyldMachOARM, llvm::RuntimeDyldCOFFThumb, llvm::RuntimeDyldCOFFI386, llvm::RuntimeDyldMachOI386, and llvm::RuntimeDyldMachOX86_64.

◆ readBytesUnaligned()

uint64_t llvm::RuntimeDyldImpl::readBytesUnaligned ( uint8_t *  Src,
unsigned  Size 
) const

◆ reassignSectionAddress()

void llvm::RuntimeDyldImpl::reassignSectionAddress ( unsigned  SectionID,
uint64_t  Addr 

Definition at line 969 of file RuntimeDyld.cpp.

References llvm::dbgs(), DEBUG, llvm::format(), and getName().

◆ registerEHFrames()

void llvm::RuntimeDyldImpl::registerEHFrames ( )

◆ relocationNeedsGot()

virtual bool llvm::RuntimeDyldImpl::relocationNeedsGot ( const RelocationRef R) const

Definition at line 459 of file RuntimeDyldImpl.h.

◆ relocationNeedsStub()

virtual bool llvm::RuntimeDyldImpl::relocationNeedsStub ( const RelocationRef R) const

Definition at line 464 of file RuntimeDyldImpl.h.

◆ resolveExternalSymbols()

Error llvm::RuntimeDyldImpl::resolveExternalSymbols ( )

Resolve relocations to external symbols.

Definition at line 999 of file RuntimeDyld.cpp.

References llvm::StringRef::data(), llvm::dbgs(), DEBUG, llvm::format(), llvm::report_fatal_error(), llvm::StringRef::size(), and llvm::Error::success().

◆ resolveRelocation()

virtual void llvm::RuntimeDyldImpl::resolveRelocation ( const RelocationEntry RE,
uint64_t  Value 
protectedpure virtual

A object file specific relocation resolver.

REThe relocation to be resolved
ValueTarget symbol address to apply the relocation action

Implemented in llvm::RuntimeDyldMachOAArch64, llvm::RuntimeDyldMachOARM, llvm::RuntimeDyldELF, llvm::RuntimeDyldCOFFThumb, llvm::RuntimeDyldCOFFI386, llvm::RuntimeDyldMachOI386, llvm::RuntimeDyldMachOX86_64, llvm::RuntimeDyldCOFFX86_64, and llvm::RuntimeDyldELFMips.

◆ resolveRelocationList()

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

Resolves relocations from Relocs list with address from Value.

Definition at line 988 of file RuntimeDyld.cpp.

References llvm::RelocationEntry::SectionID, and llvm::SmallVectorTemplateCommon< T, typename >::size().

◆ resolveRelocations()

void llvm::RuntimeDyldImpl::resolveRelocations ( )

◆ setMipsABI()

virtual void llvm::RuntimeDyldImpl::setMipsABI ( const ObjectFile Obj)

Definition at line 359 of file RuntimeDyldImpl.h.

References llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Size.

◆ setProcessAllSections()

void llvm::RuntimeDyldImpl::setProcessAllSections ( bool  ProcessAllSections)

Definition at line 477 of file RuntimeDyldImpl.h.

◆ setRuntimeDyldChecker()

void llvm::RuntimeDyldImpl::setRuntimeDyldChecker ( RuntimeDyldCheckerImpl Checker)

Definition at line 481 of file RuntimeDyldImpl.h.

◆ writeBytesUnaligned()

void llvm::RuntimeDyldImpl::writeBytesUnaligned ( uint64_t  Value,
uint8_t *  Dst,
unsigned  Size 
) const

◆ writeInt16BE()

void llvm::RuntimeDyldImpl::writeInt16BE ( uint8_t *  Addr,
uint16_t  Value 

Definition at line 330 of file RuntimeDyldImpl.h.

References llvm::sys::swapByteOrder().

Referenced by llvm::applyPPChighesta().

◆ writeInt32BE()

void llvm::RuntimeDyldImpl::writeInt32BE ( uint8_t *  Addr,
uint32_t  Value 

◆ writeInt64BE()

void llvm::RuntimeDyldImpl::writeInt64BE ( uint8_t *  Addr,
uint64_t  Value 

Definition at line 346 of file RuntimeDyldImpl.h.

References llvm::sys::swapByteOrder().

Referenced by llvm::applyPPChighesta().

Friends And Related Function Documentation

◆ RuntimeDyld::LoadedObjectInfo

friend class RuntimeDyld::LoadedObjectInfo

Definition at line 243 of file RuntimeDyldImpl.h.

◆ RuntimeDyldCheckerImpl

friend class RuntimeDyldCheckerImpl

Definition at line 244 of file RuntimeDyldImpl.h.

Member Data Documentation

◆ AbsoluteSymbolSection

const unsigned llvm::RuntimeDyldImpl::AbsoluteSymbolSection = ~0U

Definition at line 246 of file RuntimeDyldImpl.h.

◆ Arch

Triple::ArchType llvm::RuntimeDyldImpl::Arch

◆ Checker

RuntimeDyldCheckerImpl* llvm::RuntimeDyldImpl::Checker

Definition at line 255 of file RuntimeDyldImpl.h.

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

◆ ErrorStr

std::string llvm::RuntimeDyldImpl::ErrorStr

Definition at line 320 of file RuntimeDyldImpl.h.

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

◆ ExternalSymbolRelocations

StringMap<RelocationList> llvm::RuntimeDyldImpl::ExternalSymbolRelocations

Definition at line 289 of file RuntimeDyldImpl.h.

◆ GlobalSymbolTable

RTDyldSymbolTable llvm::RuntimeDyldImpl::GlobalSymbolTable

◆ HasError

bool llvm::RuntimeDyldImpl::HasError

Definition at line 319 of file RuntimeDyldImpl.h.

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

◆ IsMipsN32ABI

bool llvm::RuntimeDyldImpl::IsMipsN32ABI

◆ IsMipsN64ABI

bool llvm::RuntimeDyldImpl::IsMipsN64ABI

◆ IsMipsO32ABI

bool llvm::RuntimeDyldImpl::IsMipsO32ABI

◆ IsTargetLittleEndian

bool llvm::RuntimeDyldImpl::IsTargetLittleEndian

Definition at line 295 of file RuntimeDyldImpl.h.

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

◆ lock

sys::Mutex llvm::RuntimeDyldImpl::lock

Definition at line 314 of file RuntimeDyldImpl.h.

◆ MemMgr

RuntimeDyld::MemoryManager& llvm::RuntimeDyldImpl::MemMgr

◆ ProcessAllSections

bool llvm::RuntimeDyldImpl::ProcessAllSections

Definition at line 302 of file RuntimeDyldImpl.h.

◆ Relocations

std::unordered_map<unsigned, RelocationList> llvm::RuntimeDyldImpl::Relocations

Definition at line 284 of file RuntimeDyldImpl.h.

◆ Resolver

JITSymbolResolver& llvm::RuntimeDyldImpl::Resolver

◆ Sections

SectionList llvm::RuntimeDyldImpl::Sections

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