LLVM  5.0.0
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:
[legend]
Collaboration diagram for llvm::RuntimeDyldImpl:
[legend]

Public Member Functions

 RuntimeDyldImpl (RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
 
virtual ~RuntimeDyldImpl ()
 
void setProcessAllSections (bool ProcessAllSections)
 
void setRuntimeDyldChecker (RuntimeDyldCheckerImpl *Checker)
 
virtual std::unique_ptr
< RuntimeDyld::LoadedObjectInfo > 
loadObject (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,
unsigned > 
ObjSectionToIDMap
 
typedef std::vector< SymbolRef > CommonSymbolList
 
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...
 
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< unsigned > emitSection (const ObjectFile &Obj, const SectionRef &Section, bool IsCode)
 Emits section data from the object file to the MemoryManager. More...
 
Expected< unsigned > findOrEmitSection (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_iterator > 
processRelocationRef (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< ObjSectionToIDMap > loadObjectImpl (const object::ObjectFile &Obj)
 
virtual size_t getGOTEntrySize ()
 
virtual bool relocationNeedsGot (const RelocationRef &R) const
 
virtual bool relocationNeedsStub (const RelocationRef &R) const
 

Protected Attributes

RuntimeDyld::MemoryManager & MemMgr
 
JITSymbolResolver & Resolver
 
RuntimeDyldCheckerImpl * Checker
 
SectionList Sections
 
RTDyldSymbolTable GlobalSymbolTable
 
std::unordered_map< unsigned,
RelocationList > 
Relocations
 
StringMap< RelocationList > ExternalSymbolRelocations
 
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
 

Friends

class RuntimeDyld::LoadedObjectInfo
 
class RuntimeDyldCheckerImpl
 

Detailed Description

Definition at line 238 of file RuntimeDyldImpl.h.

Member Typedef Documentation

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

Definition at line 269 of file RuntimeDyldImpl.h.

Definition at line 263 of file RuntimeDyldImpl.h.

Definition at line 276 of file RuntimeDyldImpl.h.

Definition at line 255 of file RuntimeDyldImpl.h.

Definition at line 258 of file RuntimeDyldImpl.h.

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

Definition at line 288 of file RuntimeDyldImpl.h.

Constructor & Destructor Documentation

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

Definition at line 453 of file RuntimeDyldImpl.h.

RuntimeDyldImpl::~RuntimeDyldImpl ( )
virtual

Definition at line 67 of file RuntimeDyld.cpp.

Member Function Documentation

void llvm::RuntimeDyldImpl::addRelocationForSection ( const RelocationEntry &  RE,
unsigned  SectionID 
)
protected
void llvm::RuntimeDyldImpl::addRelocationForSymbol ( const RelocationEntry &  RE,
StringRef  SymbolName 
)
protected
void llvm::RuntimeDyldImpl::clearError ( )
inline

Definition at line 509 of file RuntimeDyldImpl.h.

unsigned llvm::RuntimeDyldImpl::computeGOTSize ( const ObjectFile &  Obj)
protected
unsigned llvm::RuntimeDyldImpl::computeSectionStubBufSize ( const ObjectFile &  Obj,
const SectionRef &  Section 
)
protected
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 
)
protected
uint8_t * llvm::RuntimeDyldImpl::createStubFunction ( uint8_t *  Addr,
unsigned  AbiVariant = 0 
)
protected
void llvm::RuntimeDyldImpl::deregisterEHFrames ( )

Definition at line 76 of file RuntimeDyld.cpp.

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

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 619 of file RuntimeDyld.cpp.

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

Expected< unsigned > llvm::RuntimeDyldImpl::emitSection ( const ObjectFile &  Obj,
const SectionRef &  Section,
bool  IsCode 
)
protected
virtual Error llvm::RuntimeDyldImpl::finalizeLoad ( const ObjectFile &  ObjImg,
ObjSectionToIDMap &  SectionMap 
)
inlinevirtual
Expected< unsigned > llvm::RuntimeDyldImpl::findOrEmitSection ( const ObjectFile &  Obj,
const SectionRef &  Section,
bool  IsCode,
ObjSectionToIDMap &  LocalSections 
)
protected

Find Section in LocalSections.

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

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

Definition at line 809 of file RuntimeDyld.cpp.

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

Referenced by llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), and llvm::RuntimeDyldELF::processRelocationRef().

StringRef llvm::RuntimeDyldImpl::getErrorString ( )
inline

Definition at line 512 of file RuntimeDyldImpl.h.

virtual size_t llvm::RuntimeDyldImpl::getGOTEntrySize ( )
inlineprotectedvirtual

Reimplemented in llvm::RuntimeDyldELF.

Definition at line 440 of file RuntimeDyldImpl.h.

virtual unsigned llvm::RuntimeDyldImpl::getMaxStubSize ( )
protectedpure virtual
uint8_t* llvm::RuntimeDyldImpl::getSectionAddress ( unsigned  SectionID) const
inlineprotected

Definition at line 322 of file RuntimeDyldImpl.h.

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

Definition at line 318 of file RuntimeDyldImpl.h.

virtual unsigned llvm::RuntimeDyldImpl::getStubAlignment ( )
protectedpure virtual
JITEvaluatedSymbol llvm::RuntimeDyldImpl::getSymbol ( StringRef  Name) const
inline

Definition at line 485 of file RuntimeDyldImpl.h.

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

Definition at line 472 of file RuntimeDyldImpl.h.

bool llvm::RuntimeDyldImpl::hasError ( )
inline

Definition at line 506 of file RuntimeDyldImpl.h.

virtual bool llvm::RuntimeDyldImpl::isCompatibleFile ( const ObjectFile &  Obj) const
pure virtual
virtual std::unique_ptr<RuntimeDyld::LoadedObjectInfo> llvm::RuntimeDyldImpl::loadObject ( const object::ObjectFile &  Obj)
pure virtual
Expected< RuntimeDyldImpl::ObjSectionToIDMap > llvm::RuntimeDyldImpl::loadObjectImpl ( const object::ObjectFile &  Obj)
protected
void llvm::RuntimeDyldImpl::mapSectionAddress ( const void *  LocalAddress,
uint64_t  TargetAddress 
)

Definition at line 157 of file RuntimeDyld.cpp.

References llvm_unreachable().

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

Returns
Iterator to the next relocation that needs to be parsed.

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

uint64_t llvm::RuntimeDyldImpl::readBytesUnaligned ( uint8_t *  Src,
unsigned  Size 
) const
protected
void llvm::RuntimeDyldImpl::reassignSectionAddress ( unsigned  SectionID,
uint64_t  Addr 
)

Definition at line 931 of file RuntimeDyld.cpp.

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

void llvm::RuntimeDyldImpl::registerEHFrames ( )
virtual
virtual bool llvm::RuntimeDyldImpl::relocationNeedsGot ( const RelocationRef &  R) const
inlineprotectedvirtual

Definition at line 443 of file RuntimeDyldImpl.h.

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

Definition at line 448 of file RuntimeDyldImpl.h.

Error llvm::RuntimeDyldImpl::resolveExternalSymbols ( )
protected

Resolve relocations to external symbols.

Definition at line 961 of file RuntimeDyld.cpp.

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

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

A object file specific relocation resolver.

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

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

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

Resolves relocations from Relocs list with address from Value.

Definition at line 950 of file RuntimeDyld.cpp.

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

void llvm::RuntimeDyldImpl::resolveRelocations ( )
virtual void llvm::RuntimeDyldImpl::setMipsABI ( const ObjectFile &  Obj)
inlineprotectedvirtual

Definition at line 355 of file RuntimeDyldImpl.h.

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

Definition at line 461 of file RuntimeDyldImpl.h.

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

Definition at line 465 of file RuntimeDyldImpl.h.

void llvm::RuntimeDyldImpl::writeBytesUnaligned ( uint64_t  Value,
uint8_t *  Dst,
unsigned  Size 
) const
protected
void llvm::RuntimeDyldImpl::writeInt16BE ( uint8_t *  Addr,
uint16_t  Value 
)
inlineprotected

Definition at line 326 of file RuntimeDyldImpl.h.

References llvm::sys::swapByteOrder().

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

Definition at line 333 of file RuntimeDyldImpl.h.

References llvm::sys::swapByteOrder().

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

Definition at line 342 of file RuntimeDyldImpl.h.

References llvm::sys::swapByteOrder().

Friends And Related Function Documentation

friend class RuntimeDyld::LoadedObjectInfo
friend

Definition at line 239 of file RuntimeDyldImpl.h.

friend class RuntimeDyldCheckerImpl
friend

Definition at line 240 of file RuntimeDyldImpl.h.

Member Data Documentation

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

Definition at line 242 of file RuntimeDyldImpl.h.

Triple::ArchType llvm::RuntimeDyldImpl::Arch
protected
RuntimeDyldCheckerImpl* llvm::RuntimeDyldImpl::Checker
protected

Definition at line 251 of file RuntimeDyldImpl.h.

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

std::string llvm::RuntimeDyldImpl::ErrorStr
protected

Definition at line 316 of file RuntimeDyldImpl.h.

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

StringMap<RelocationList> llvm::RuntimeDyldImpl::ExternalSymbolRelocations
protected

Definition at line 285 of file RuntimeDyldImpl.h.

RTDyldSymbolTable llvm::RuntimeDyldImpl::GlobalSymbolTable
protected

Definition at line 266 of file RuntimeDyldImpl.h.

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

bool llvm::RuntimeDyldImpl::HasError
protected

Definition at line 315 of file RuntimeDyldImpl.h.

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

bool llvm::RuntimeDyldImpl::IsMipsN32ABI
protected
bool llvm::RuntimeDyldImpl::IsMipsN64ABI
protected
bool llvm::RuntimeDyldImpl::IsMipsO32ABI
protected
bool llvm::RuntimeDyldImpl::IsTargetLittleEndian
protected

Definition at line 291 of file RuntimeDyldImpl.h.

sys::Mutex llvm::RuntimeDyldImpl::lock
protected

Definition at line 310 of file RuntimeDyldImpl.h.

RuntimeDyld::MemoryManager& llvm::RuntimeDyldImpl::MemMgr
protected
bool llvm::RuntimeDyldImpl::ProcessAllSections
protected

Definition at line 298 of file RuntimeDyldImpl.h.

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

Definition at line 280 of file RuntimeDyldImpl.h.

JITSymbolResolver& llvm::RuntimeDyldImpl::Resolver
protected

Definition at line 248 of file RuntimeDyldImpl.h.

SectionList llvm::RuntimeDyldImpl::Sections
protected

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