LLVM API Documentation
#include <RuntimeDyldImpl.h>
Public Member Functions | |
RuntimeDyldImpl (RTDyldMemoryManager *mm) | |
virtual | ~RuntimeDyldImpl () |
void | setProcessAllSections (bool ProcessAllSections) |
void | setRuntimeDyldChecker (RuntimeDyldCheckerImpl *Checker) |
std::unique_ptr< ObjectImage > | loadObject (std::unique_ptr< ObjectImage > InputObject) |
uint8_t * | getSymbolAddress (StringRef Name) const |
uint64_t | getSymbolLoadAddress (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 | isCompatibleFormat (const ObjectBuffer *Buffer) const =0 |
virtual bool | isCompatibleFile (const ObjectFile *Obj) const =0 |
virtual void | registerEHFrames () |
virtual void | deregisterEHFrames () |
virtual void | finalizeLoad (ObjectImage &ObjImg, ObjSectionToIDMap &SectionMap) |
Protected Types | |
typedef SmallVector < SectionEntry, 64 > | SectionList |
typedef unsigned | SID |
typedef std::map< SectionRef, unsigned > | ObjSectionToIDMap |
typedef std::pair< unsigned, uintptr_t > | SymbolLoc |
typedef StringMap< SymbolLoc > | SymbolTableMap |
typedef std::pair< unsigned, unsigned > | CommonSymbolInfo |
typedef std::map< SymbolRef, CommonSymbolInfo > | CommonSymbolMap |
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) |
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 |
void | emitCommonSymbols (ObjectImage &Obj, const CommonSymbolMap &CommonSymbols, uint64_t TotalSize, SymbolTableMap &SymbolTable) |
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 (ObjectImage &Obj, const SectionRef &Section, bool IsCode) |
Emits section data from the object file to the MemoryManager. | |
unsigned | findOrEmitSection (ObjectImage &Obj, const SectionRef &Section, bool IsCode, ObjSectionToIDMap &LocalSections) |
Find Section in LocalSections. If the secton is not found - emit it and store 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, ObjectImage &Obj, ObjSectionToIDMap &ObjSectionToID, const SymbolTableMap &Symbols, 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. | |
virtual void | updateGOTEntries (StringRef Name, uint64_t Addr) |
Update GOT entries for external symbols. | |
void | computeTotalAllocSize (ObjectImage &Obj, uint64_t &CodeSize, uint64_t &DataSizeRO, uint64_t &DataSizeRW) |
unsigned | computeSectionStubBufSize (ObjectImage &Obj, const SectionRef &Section) |
Protected Attributes | |
RTDyldMemoryManager * | MemMgr |
RuntimeDyldCheckerImpl * | Checker |
SectionList | Sections |
SymbolTableMap | GlobalSymbolTable |
DenseMap< unsigned, RelocationList > | Relocations |
StringMap< RelocationList > | ExternalSymbolRelocations |
Triple::ArchType | Arch |
bool | IsTargetLittleEndian |
bool | ProcessAllSections |
sys::Mutex | lock |
bool | HasError |
std::string | ErrorStr |
Friends | |
class | RuntimeDyldCheckerImpl |
Definition at line 161 of file RuntimeDyldImpl.h.
typedef std::pair<unsigned, unsigned> llvm::RuntimeDyldImpl::CommonSymbolInfo [protected] |
Definition at line 197 of file RuntimeDyldImpl.h.
typedef std::map<SymbolRef, CommonSymbolInfo> llvm::RuntimeDyldImpl::CommonSymbolMap [protected] |
Definition at line 199 of file RuntimeDyldImpl.h.
typedef std::map<SectionRef, unsigned> llvm::RuntimeDyldImpl::ObjSectionToIDMap [protected] |
Definition at line 188 of file RuntimeDyldImpl.h.
typedef SmallVector<RelocationEntry, 64> llvm::RuntimeDyldImpl::RelocationList [protected] |
Definition at line 206 of file RuntimeDyldImpl.h.
typedef SmallVector<SectionEntry, 64> llvm::RuntimeDyldImpl::SectionList [protected] |
Definition at line 180 of file RuntimeDyldImpl.h.
typedef unsigned llvm::RuntimeDyldImpl::SID [protected] |
Definition at line 183 of file RuntimeDyldImpl.h.
typedef std::map<RelocationValueRef, uintptr_t> llvm::RuntimeDyldImpl::StubMap [protected] |
Definition at line 218 of file RuntimeDyldImpl.h.
typedef std::pair<unsigned, uintptr_t> llvm::RuntimeDyldImpl::SymbolLoc [protected] |
Definition at line 192 of file RuntimeDyldImpl.h.
typedef StringMap<SymbolLoc> llvm::RuntimeDyldImpl::SymbolTableMap [protected] |
Definition at line 193 of file RuntimeDyldImpl.h.
llvm::RuntimeDyldImpl::RuntimeDyldImpl | ( | RTDyldMemoryManager * | mm | ) | [inline] |
Definition at line 362 of file RuntimeDyldImpl.h.
RuntimeDyldImpl::~RuntimeDyldImpl | ( | ) | [virtual] |
Definition at line 31 of file RuntimeDyld.cpp.
void llvm::RuntimeDyldImpl::addRelocationForSection | ( | const RelocationEntry & | RE, |
unsigned | SectionID | ||
) | [protected] |
void llvm::RuntimeDyldImpl::addRelocationForSymbol | ( | const RelocationEntry & | RE, |
StringRef | SymbolName | ||
) | [protected] |
Definition at line 579 of file RuntimeDyld.cpp.
References llvm::RelocationEntry::Addend, and llvm::StringMapEntry< ValueTy >::second.
Referenced by llvm::RuntimeDyldMachOI386::processRelocationRef(), llvm::RuntimeDyldMachOX86_64::processRelocationRef(), llvm::RuntimeDyldMachOARM::processRelocationRef(), and llvm::RuntimeDyldMachOAArch64::processRelocationRef().
void llvm::RuntimeDyldImpl::clearError | ( | ) | [inline] |
Definition at line 409 of file RuntimeDyldImpl.h.
unsigned llvm::RuntimeDyldImpl::computeSectionStubBufSize | ( | ObjectImage & | Obj, |
const SectionRef & | Section | ||
) | [protected] |
Definition at line 361 of file RuntimeDyld.cpp.
References llvm::ObjectImage::begin_sections(), Check(), llvm::ObjectImage::end_sections(), llvm::object::SectionRef::getAlignment(), and llvm::object::SectionRef::getSize().
void llvm::RuntimeDyldImpl::computeTotalAllocSize | ( | ObjectImage & | Obj, |
uint64_t & | CodeSize, | ||
uint64_t & | DataSizeRO, | ||
uint64_t & | DataSizeRW | ||
) | [protected] |
Definition at line 273 of file RuntimeDyld.cpp.
References llvm::ObjectImage::begin_sections(), llvm::ObjectImage::begin_symbols(), Check(), llvm::computeAllocationSizeForSections(), llvm::ObjectImage::end_sections(), llvm::ObjectImage::end_symbols(), llvm::object::SectionRef::getAlignment(), llvm::object::SectionRef::getName(), llvm::object::SectionRef::getSize(), I, llvm::object::SectionRef::isReadOnlyData(), llvm::object::SectionRef::isRequiredForExecution(), llvm::object::SectionRef::isText(), Name, llvm::ARMBuildAttrs::Section, llvm::COFF::SectionSize, and llvm::object::BasicSymbolRef::SF_Common.
uint8_t * llvm::RuntimeDyldImpl::createStubFunction | ( | uint8_t * | Addr, |
unsigned | AbiVariant = 0 |
||
) | [protected] |
Emits long jump instruction to Addr.
Definition at line 595 of file RuntimeDyld.cpp.
References llvm::Triple::aarch64, llvm::Triple::aarch64_be, llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::mips, llvm::Triple::mipsel, llvm::Triple::ppc64, llvm::Triple::ppc64le, llvm::Triple::systemz, llvm::Triple::x86, and llvm::Triple::x86_64.
void llvm::RuntimeDyldImpl::deregisterEHFrames | ( | ) | [virtual] |
Reimplemented in llvm::RuntimeDyldELF.
Definition at line 42 of file RuntimeDyld.cpp.
void llvm::RuntimeDyldImpl::emitCommonSymbols | ( | ObjectImage & | Obj, |
const CommonSymbolMap & | CommonSymbols, | ||
uint64_t | TotalSize, | ||
SymbolTableMap & | SymbolTable | ||
) | [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 428 of file RuntimeDyld.cpp.
References Align(), llvm::StringRef::data(), llvm::dbgs(), DEBUG, llvm::format(), llvm::LibFunc::memset, Name, llvm::OffsetToAlignment(), llvm::report_fatal_error(), and llvm::ObjectImage::updateSymbolAddress().
unsigned llvm::RuntimeDyldImpl::emitSection | ( | ObjectImage & | Obj, |
const SectionRef & | Section, | ||
bool | IsCode | ||
) | [protected] |
Emits section data from the object file to the MemoryManager.
IsCode | if it's true then allocateCodeSection() will be used for emits, else allocateDataSection() will be used. |
Definition at line 467 of file RuntimeDyld.cpp.
References Check(), llvm::StringRef::data(), llvm::dbgs(), DEBUG, llvm::format(), llvm::object::SectionRef::getAlignment(), llvm::object::SectionRef::getContents(), llvm::ObjectImage::getImageName(), llvm::object::SectionRef::getName(), llvm::object::SectionRef::getSize(), llvm::object::SectionRef::isReadOnlyData(), llvm::object::SectionRef::isRequiredForExecution(), llvm::object::SectionRef::isVirtual(), llvm::object::SectionRef::isZeroInit(), llvm::LibFunc::memcpy, llvm::LibFunc::memset, Name, llvm::report_fatal_error(), and llvm::ObjectImage::updateSectionAddress().
bool llvm::RuntimeDyldImpl::Error | ( | const Twine & | Msg | ) | [inline, protected] |
Definition at line 246 of file RuntimeDyldImpl.h.
References llvm::Twine::str().
Referenced by llvm::RuntimeDyldMachOX86_64::resolveRelocation(), llvm::RuntimeDyldMachOI386::resolveRelocation(), and llvm::RuntimeDyldMachOARM::resolveRelocation().
virtual void llvm::RuntimeDyldImpl::finalizeLoad | ( | ObjectImage & | ObjImg, |
ObjSectionToIDMap & | SectionMap | ||
) | [inline, virtual] |
Reimplemented in llvm::RuntimeDyldMachOCRTPBase< Impl >, llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOI386 >, llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOAArch64 >, llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOARM >, llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOX86_64 >, and llvm::RuntimeDyldELF.
Definition at line 421 of file RuntimeDyldImpl.h.
unsigned llvm::RuntimeDyldImpl::findOrEmitSection | ( | ObjectImage & | 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.
IsCode | if it's true then allocateCodeSection() will be used for emmits, else allocateDataSection() will be used. |
Definition at line 558 of file RuntimeDyld.cpp.
References llvm::ARMBuildAttrs::Section.
StringRef llvm::RuntimeDyldImpl::getErrorString | ( | ) | [inline] |
Definition at line 412 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 256 of file RuntimeDyldImpl.h.
uint64_t llvm::RuntimeDyldImpl::getSectionLoadAddress | ( | unsigned | SectionID | ) | const [inline, protected] |
Definition at line 252 of file RuntimeDyldImpl.h.
virtual unsigned llvm::RuntimeDyldImpl::getStubAlignment | ( | ) | [protected, pure virtual] |
uint8_t* llvm::RuntimeDyldImpl::getSymbolAddress | ( | StringRef | Name | ) | const [inline] |
Definition at line 379 of file RuntimeDyldImpl.h.
References llvm::StringMapEntry< ValueTy >::second.
uint64_t llvm::RuntimeDyldImpl::getSymbolLoadAddress | ( | StringRef | Name | ) | const [inline] |
Definition at line 389 of file RuntimeDyldImpl.h.
References llvm::StringMapEntry< ValueTy >::second.
bool llvm::RuntimeDyldImpl::hasError | ( | ) | [inline] |
Definition at line 406 of file RuntimeDyldImpl.h.
virtual bool llvm::RuntimeDyldImpl::isCompatibleFile | ( | const ObjectFile * | Obj | ) | const [pure virtual] |
Implemented in llvm::RuntimeDyldMachO, and llvm::RuntimeDyldELF.
virtual bool llvm::RuntimeDyldImpl::isCompatibleFormat | ( | const ObjectBuffer * | Buffer | ) | const [pure virtual] |
Implemented in llvm::RuntimeDyldMachO, and llvm::RuntimeDyldELF.
std::unique_ptr< ObjectImage > llvm::RuntimeDyldImpl::loadObject | ( | std::unique_ptr< ObjectImage > | InputObject | ) |
Definition at line 141 of file RuntimeDyld.cpp.
References Align(), Check(), llvm::StringRef::data(), llvm::dbgs(), DEBUG, llvm::format(), llvm::getOffset(), I, Name, llvm::object::BasicSymbolRef::SF_Common, llvm::object::SymbolRef::ST_Data, llvm::object::SymbolRef::ST_Function, and llvm::object::SymbolRef::ST_Unknown.
void llvm::RuntimeDyldImpl::mapSectionAddress | ( | const void * | LocalAddress, |
uint64_t | TargetAddress | ||
) |
Definition at line 100 of file RuntimeDyld.cpp.
References llvm_unreachable.
virtual relocation_iterator llvm::RuntimeDyldImpl::processRelocationRef | ( | unsigned | SectionID, |
relocation_iterator | RelI, | ||
ObjectImage & | Obj, | ||
ObjSectionToIDMap & | ObjSectionToID, | ||
const SymbolTableMap & | Symbols, | ||
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).
Implemented in llvm::RuntimeDyldMachOAArch64, llvm::RuntimeDyldELF, llvm::RuntimeDyldMachOARM, llvm::RuntimeDyldMachOI386, and llvm::RuntimeDyldMachOX86_64.
uint64_t llvm::RuntimeDyldImpl::readBytesUnaligned | ( | uint8_t * | Src, |
unsigned | Size | ||
) | const [protected] |
Endian-aware read Read the least significant Size bytes from Src.
Definition at line 398 of file RuntimeDyld.cpp.
void llvm::RuntimeDyldImpl::reassignSectionAddress | ( | unsigned | SectionID, |
uint64_t | Addr | ||
) |
Definition at line 684 of file RuntimeDyld.cpp.
References llvm::dbgs(), DEBUG, llvm::format(), and Name.
void llvm::RuntimeDyldImpl::registerEHFrames | ( | ) | [virtual] |
Reimplemented in llvm::RuntimeDyldMachOCRTPBase< Impl >, llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOI386 >, llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOAArch64 >, llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOARM >, llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOX86_64 >, and llvm::RuntimeDyldELF.
Definition at line 40 of file RuntimeDyld.cpp.
void llvm::RuntimeDyldImpl::resolveExternalSymbols | ( | ) | [protected] |
Resolve relocations to external symbols.
Definition at line 714 of file RuntimeDyld.cpp.
References llvm::StringMap< ValueTy, AllocatorTy >::begin(), llvm::StringRef::data(), llvm::dbgs(), DEBUG, llvm::StringMap< ValueTy, AllocatorTy >::find(), llvm::format(), Name, llvm::report_fatal_error(), llvm::StringMapEntry< ValueTy >::second, and llvm::StringRef::size().
virtual void llvm::RuntimeDyldImpl::resolveRelocation | ( | const RelocationEntry & | RE, |
uint64_t | Value | ||
) | [protected, pure virtual] |
A object file specific relocation resolver.
RE | The relocation to be resolved |
Value | Target symbol address to apply the relocation action |
Implemented in llvm::RuntimeDyldMachOAArch64, llvm::RuntimeDyldELF, llvm::RuntimeDyldMachOARM, llvm::RuntimeDyldMachOI386, and llvm::RuntimeDyldMachOX86_64.
void llvm::RuntimeDyldImpl::resolveRelocationList | ( | const RelocationList & | Relocs, |
uint64_t | Value | ||
) | [protected] |
Resolves relocations from Relocs list with address from Value.
Definition at line 703 of file RuntimeDyld.cpp.
References llvm::RelocationEntry::SectionID, and llvm::SmallVectorTemplateCommon< T, typename >::size().
Definition at line 78 of file RuntimeDyld.cpp.
References llvm::dbgs(), DEBUG, llvm::dumpSectionMemory(), and llvm::format().
void llvm::RuntimeDyldImpl::setProcessAllSections | ( | bool | ProcessAllSections | ) | [inline] |
Definition at line 368 of file RuntimeDyldImpl.h.
void llvm::RuntimeDyldImpl::setRuntimeDyldChecker | ( | RuntimeDyldCheckerImpl * | Checker | ) | [inline] |
Definition at line 372 of file RuntimeDyldImpl.h.
virtual void llvm::RuntimeDyldImpl::updateGOTEntries | ( | StringRef | Name, |
uint64_t | Addr | ||
) | [inline, protected, virtual] |
Update GOT entries for external symbols.
Definition at line 350 of file RuntimeDyldImpl.h.
void llvm::RuntimeDyldImpl::writeBytesUnaligned | ( | uint64_t | Value, |
uint8_t * | Dst, | ||
unsigned | Size | ||
) | const [protected] |
Endian-aware write. Write the least significant Size bytes from Value to Dst.
Definition at line 412 of file RuntimeDyld.cpp.
Referenced by llvm::RuntimeDyldMachOX86_64::resolveRelocation(), llvm::RuntimeDyldMachOI386::resolveRelocation(), and llvm::RuntimeDyldMachOARM::resolveRelocation().
void llvm::RuntimeDyldImpl::writeInt16BE | ( | uint8_t * | Addr, |
uint16_t | Value | ||
) | [inline, protected] |
Definition at line 260 of file RuntimeDyldImpl.h.
References llvm::sys::swapByteOrder().
void llvm::RuntimeDyldImpl::writeInt32BE | ( | uint8_t * | Addr, |
uint32_t | Value | ||
) | [inline, protected] |
Definition at line 267 of file RuntimeDyldImpl.h.
References llvm::sys::swapByteOrder().
void llvm::RuntimeDyldImpl::writeInt64BE | ( | uint8_t * | Addr, |
uint64_t | Value | ||
) | [inline, protected] |
Definition at line 276 of file RuntimeDyldImpl.h.
References llvm::sys::swapByteOrder().
friend class RuntimeDyldCheckerImpl [friend] |
Definition at line 162 of file RuntimeDyldImpl.h.
Triple::ArchType llvm::RuntimeDyldImpl::Arch [protected] |
Definition at line 220 of file RuntimeDyldImpl.h.
RuntimeDyldCheckerImpl* llvm::RuntimeDyldImpl::Checker [protected] |
Definition at line 176 of file RuntimeDyldImpl.h.
std::string llvm::RuntimeDyldImpl::ErrorStr [protected] |
Definition at line 243 of file RuntimeDyldImpl.h.
Definition at line 215 of file RuntimeDyldImpl.h.
Definition at line 194 of file RuntimeDyldImpl.h.
bool llvm::RuntimeDyldImpl::HasError [protected] |
Definition at line 242 of file RuntimeDyldImpl.h.
bool llvm::RuntimeDyldImpl::IsTargetLittleEndian [protected] |
Definition at line 221 of file RuntimeDyldImpl.h.
sys::Mutex llvm::RuntimeDyldImpl::lock [protected] |
Definition at line 237 of file RuntimeDyldImpl.h.
RTDyldMemoryManager* llvm::RuntimeDyldImpl::MemMgr [protected] |
Definition at line 173 of file RuntimeDyldImpl.h.
bool llvm::RuntimeDyldImpl::ProcessAllSections [protected] |
Definition at line 225 of file RuntimeDyldImpl.h.
DenseMap<unsigned, RelocationList> llvm::RuntimeDyldImpl::Relocations [protected] |
Definition at line 210 of file RuntimeDyldImpl.h.
SectionList llvm::RuntimeDyldImpl::Sections [protected] |
Definition at line 181 of file RuntimeDyldImpl.h.
Referenced by llvm::RuntimeDyldMachOAArch64::decodeAddend(), llvm::RuntimeDyldMachOARM::decodeAddend(), llvm::RuntimeDyldMachOX86_64::resolveRelocation(), llvm::RuntimeDyldMachOI386::resolveRelocation(), llvm::RuntimeDyldMachOARM::resolveRelocation(), and llvm::RuntimeDyldMachOAArch64::resolveRelocation().