LLVM  mainline
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
llvm::RuntimeDyldImpl Class Reference

#include <RuntimeDyldImpl.h>

Inheritance diagram for llvm::RuntimeDyldImpl:
Inheritance graph
[legend]
Collaboration diagram for llvm::RuntimeDyldImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RuntimeDyldImpl (RuntimeDyld::MemoryManager &MemMgr, RuntimeDyld::SymbolResolver &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
RuntimeDyld::SymbolInfo 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 ()
virtual void deregisterEHFrames ()
virtual void 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< SymbolRefCommonSymbolList
typedef SmallVector
< RelocationEntry, 64 > 
RelocationList
typedef std::map
< RelocationValueRef,
uintptr_t > 
StubMap

Protected Member Functions

virtual unsigned getMaxStubSize ()=0
virtual unsigned getStubAlignment ()=0
bool Error (const Twine &Msg)
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.
void writeBytesUnaligned (uint64_t Value, uint8_t *Dst, unsigned Size) const
 Endian-aware write.
void 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.
unsigned emitSection (const ObjectFile &Obj, const SectionRef &Section, bool IsCode)
 Emits section data from the object file to the MemoryManager.
unsigned findOrEmitSection (const ObjectFile &Obj, const SectionRef &Section, bool IsCode, ObjSectionToIDMap &LocalSections)
 Find Section in LocalSections.
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.
void resolveRelocationList (const RelocationList &Relocs, uint64_t Value)
 Resolves relocations from Relocs list with address from Value.
virtual void resolveRelocation (const RelocationEntry &RE, uint64_t Value)=0
 A object file specific relocation resolver.
virtual 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).
void resolveExternalSymbols ()
 Resolve relocations to external symbols.
void computeTotalAllocSize (const ObjectFile &Obj, uint64_t &CodeSize, uint32_t &CodeAlign, uint64_t &RODataSize, uint32_t &RODataAlign, uint64_t &RWDataSize, uint32_t &RWDataAlign)
unsigned computeSectionStubBufSize (const ObjectFile &Obj, const SectionRef &Section)
ObjSectionToIDMap loadObjectImpl (const object::ObjectFile &Obj)
virtual bool relocationNeedsStub (const RelocationRef &R) const

Protected Attributes

RuntimeDyld::MemoryManagerMemMgr
RuntimeDyld::SymbolResolverResolver
RuntimeDyldCheckerImplChecker
SectionList Sections
RTDyldSymbolTable GlobalSymbolTable
std::unordered_map< unsigned,
RelocationList
Relocations
StringMap< RelocationListExternalSymbolRelocations
Triple::ArchType Arch
bool IsTargetLittleEndian
bool IsMipsO32ABI
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 226 of file RuntimeDyldImpl.h.


Member Typedef Documentation

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

Definition at line 257 of file RuntimeDyldImpl.h.

Definition at line 251 of file RuntimeDyldImpl.h.

Definition at line 264 of file RuntimeDyldImpl.h.

Definition at line 243 of file RuntimeDyldImpl.h.

typedef unsigned llvm::RuntimeDyldImpl::SID [protected]

Definition at line 246 of file RuntimeDyldImpl.h.

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

Definition at line 276 of file RuntimeDyldImpl.h.


Constructor & Destructor Documentation

Definition at line 432 of file RuntimeDyldImpl.h.

Definition at line 31 of file RuntimeDyld.cpp.


Member Function Documentation

Definition at line 488 of file RuntimeDyldImpl.h.

void 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]

Emits long jump instruction to Addr.

Returns:
Pointer to the memory area for emitting target address.

Definition at line 696 of file RuntimeDyld.cpp.

References llvm::Triple::aarch64, llvm::Triple::aarch64_be, llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::ppc64, llvm::Triple::ppc64le, llvm::Triple::systemz, llvm::Triple::x86, and llvm::Triple::x86_64.

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

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

References llvm::Check(), llvm::dbgs(), DEBUG, llvm::Exported, llvm::format(), llvm::ErrorOr< T >::getError(), llvm::object::Binary::getFileName(), Name, llvm::None, Offset, llvm::OffsetToAlignment(), llvm::report_fatal_error(), llvm::object::BasicSymbolRef::SF_Exported, llvm::object::BasicSymbolRef::SF_Weak, and llvm::Weak.

unsigned llvm::RuntimeDyldImpl::emitSection ( const ObjectFile Obj,
const SectionRef Section,
bool  IsCode 
) [protected]

Emits section data from the object file to the MemoryManager.

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

Definition at line 561 of file RuntimeDyld.cpp.

References llvm::Check(), llvm::StringRef::data(), llvm::DataSize, llvm::dbgs(), DEBUG, llvm::format(), llvm::object::SectionRef::getAlignment(), llvm::object::SectionRef::getContents(), llvm::object::Binary::getFileName(), llvm::object::SectionRef::getName(), llvm::object::SectionRef::getSize(), llvm::isReadOnlyData(), llvm::isRequiredForExecution(), llvm::object::SectionRef::isVirtual(), llvm::isZeroInit(), Name, and llvm::report_fatal_error().

bool llvm::RuntimeDyldImpl::Error ( const Twine Msg) [inline, protected]
virtual void llvm::RuntimeDyldImpl::finalizeLoad ( const ObjectFile ObjImg,
ObjSectionToIDMap SectionMap 
) [inline, virtual]
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 658 of file RuntimeDyld.cpp.

References llvm::ARMBuildAttrs::Section.

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

Definition at line 491 of file RuntimeDyldImpl.h.

virtual unsigned llvm::RuntimeDyldImpl::getMaxStubSize ( ) [protected, pure virtual]
uint8_t* llvm::RuntimeDyldImpl::getSectionAddress ( unsigned  SectionID) const [inline, protected]

Definition at line 316 of file RuntimeDyldImpl.h.

uint64_t llvm::RuntimeDyldImpl::getSectionLoadAddress ( unsigned  SectionID) const [inline, protected]

Definition at line 312 of file RuntimeDyldImpl.h.

virtual unsigned llvm::RuntimeDyldImpl::getStubAlignment ( ) [protected, pure virtual]

Definition at line 464 of file RuntimeDyldImpl.h.

References llvm::StringMapEntry< ValueTy >::second.

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

Definition at line 451 of file RuntimeDyldImpl.h.

References llvm::StringMapEntry< ValueTy >::second.

Definition at line 485 of file RuntimeDyldImpl.h.

virtual bool llvm::RuntimeDyldImpl::isCompatibleFile ( const ObjectFile Obj) const [pure virtual]
void llvm::RuntimeDyldImpl::mapSectionAddress ( const void *  LocalAddress,
uint64_t  TargetAddress 
)

Definition at line 116 of file RuntimeDyld.cpp.

References llvm_unreachable.

virtual relocation_iterator llvm::RuntimeDyldImpl::processRelocationRef ( unsigned  SectionID,
relocation_iterator  RelI,
const ObjectFile Obj,
ObjSectionToIDMap ObjSectionToID,
StubMap Stubs 
) [protected, pure 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::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 774 of file RuntimeDyld.cpp.

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

virtual bool llvm::RuntimeDyldImpl::relocationNeedsStub ( const RelocationRef R) const [inline, protected, virtual]

Definition at line 427 of file RuntimeDyldImpl.h.

virtual void llvm::RuntimeDyldImpl::resolveRelocation ( const RelocationEntry RE,
uint64_t  Value 
) [protected, pure 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::RuntimeDyldCOFFI386, llvm::RuntimeDyldMachOARM, llvm::RuntimeDyldMachOI386, llvm::RuntimeDyldMachOX86_64, and llvm::RuntimeDyldCOFFX86_64.

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

Resolves relocations from Relocs list with address from Value.

Definition at line 793 of file RuntimeDyld.cpp.

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

Definition at line 83 of file RuntimeDyld.cpp.

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

virtual void llvm::RuntimeDyldImpl::setMipsABI ( const ObjectFile Obj) [inline, protected, virtual]

Definition at line 349 of file RuntimeDyldImpl.h.

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

Definition at line 440 of file RuntimeDyldImpl.h.

Definition at line 444 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 
) [inline, protected]

Definition at line 320 of file RuntimeDyldImpl.h.

References llvm::sys::swapByteOrder().

void llvm::RuntimeDyldImpl::writeInt32BE ( uint8_t *  Addr,
uint32_t  Value 
) [inline, protected]

Definition at line 327 of file RuntimeDyldImpl.h.

References llvm::sys::swapByteOrder().

void llvm::RuntimeDyldImpl::writeInt64BE ( uint8_t *  Addr,
uint64_t  Value 
) [inline, protected]

Definition at line 336 of file RuntimeDyldImpl.h.

References llvm::sys::swapByteOrder().


Friends And Related Function Documentation

friend class RuntimeDyld::LoadedObjectInfo [friend]

Definition at line 227 of file RuntimeDyldImpl.h.

friend class RuntimeDyldCheckerImpl [friend]

Definition at line 228 of file RuntimeDyldImpl.h.


Member Data Documentation

Definition at line 230 of file RuntimeDyldImpl.h.

Definition at line 278 of file RuntimeDyldImpl.h.

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

Definition at line 239 of file RuntimeDyldImpl.h.

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

std::string llvm::RuntimeDyldImpl::ErrorStr [protected]

Definition at line 303 of file RuntimeDyldImpl.h.

Definition at line 273 of file RuntimeDyldImpl.h.

Definition at line 254 of file RuntimeDyldImpl.h.

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

Definition at line 302 of file RuntimeDyldImpl.h.

Definition at line 279 of file RuntimeDyldImpl.h.

Definition at line 297 of file RuntimeDyldImpl.h.

Definition at line 285 of file RuntimeDyldImpl.h.

Definition at line 268 of file RuntimeDyldImpl.h.

Definition at line 236 of file RuntimeDyldImpl.h.


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