LLVM
17.0.0git
|
#include "ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h"
Static Public Member Functions | |
static void | finalizeAsync (std::unique_ptr< RuntimeDyldImpl > This, unique_function< void(object::OwningBinary< object::ObjectFile >, std::unique_ptr< RuntimeDyld::LoadedObjectInfo >, Error)> OnEmitted, object::OwningBinary< object::ObjectFile > O, std::unique_ptr< RuntimeDyld::LoadedObjectInfo > Info) |
Protected Types | |
typedef std::deque< SectionEntry > | 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 |
using | NotifyStubEmittedFunction = RuntimeDyld::NotifyStubEmittedFunction |
Protected Member Functions | |
virtual unsigned | getMaxStubSize () const =0 |
virtual Align | getStubAlignment ()=0 |
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 Expected< JITSymbolFlags > | getJITSymbolFlags (const SymbolRef &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, uint64_t CommonSize, uint32_t CommonAlign) |
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... | |
void | applyExternalSymbolRelocations (const StringMap< JITEvaluatedSymbol > ExternalSymbolMap) |
Error | resolveExternalSymbols () |
Resolve relocations to external symbols. More... | |
Error | computeTotalAllocSize (const ObjectFile &Obj, uint64_t &CodeSize, Align &CodeAlign, uint64_t &RODataSize, Align &RODataAlign, uint64_t &RWDataSize, Align &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 void | processNewSymbol (const SymbolRef &ObjSymbol, SymbolTableEntry &Entry) |
virtual bool | relocationNeedsGot (const RelocationRef &R) const |
virtual bool | relocationNeedsStub (const RelocationRef &R) const |
Protected Attributes | |
RuntimeDyld::MemoryManager & | MemMgr |
JITSymbolResolver & | Resolver |
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 |
NotifyStubEmittedFunction | NotifyStubEmitted |
bool | HasError |
std::string | ErrorStr |
Static Protected Attributes | |
static const unsigned | AbsoluteSymbolSection = ~0U |
Friends | |
class | RuntimeDyld::LoadedObjectInfo |
Definition at line 238 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 267 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 311 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 261 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 274 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 253 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 256 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 286 of file RuntimeDyldImpl.h.
|
inline |
Definition at line 453 of file RuntimeDyldImpl.h.
|
virtualdefault |
|
protected |
Definition at line 946 of file RuntimeDyld.cpp.
Referenced by llvm::RuntimeDyldMachOI386::processRelocationRef(), llvm::RuntimeDyldMachOX86_64::processRelocationRef(), llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldMachOARM::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), llvm::RuntimeDyldELF::processRelocationRef(), and llvm::RuntimeDyldMachOAArch64::processRelocationRef().
|
protected |
Definition at line 951 of file RuntimeDyld.cpp.
References llvm::RelocationEntry::Addend, assert(), and llvm::AMDGPU::HSAMD::Kernel::Key::SymbolName.
Referenced by llvm::RuntimeDyldMachOI386::processRelocationRef(), llvm::RuntimeDyldMachOX86_64::processRelocationRef(), llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldMachOARM::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), llvm::RuntimeDyldELF::processRelocationRef(), and llvm::RuntimeDyldMachOAArch64::processRelocationRef().
|
protected |
Definition at line 1110 of file RuntimeDyld.cpp.
References Addr, assert(), llvm::dbgs(), llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::StringMap< ValueTy, AllocatorTy >::find(), llvm::format(), LLVM_DEBUG, llvm::report_fatal_error(), and UINT64_MAX.
|
inline |
Definition at line 565 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 650 of file RuntimeDyld.cpp.
References llvm::object::ObjectFile::section_begin(), llvm::object::ObjectFile::section_end(), and SI.
|
protected |
Definition at line 668 of file RuntimeDyld.cpp.
References llvm::commonAlignment(), llvm::report_fatal_error(), llvm::object::ObjectFile::section_begin(), llvm::object::ObjectFile::section_end(), SI, llvm::Expected< T >::takeError(), llvm::toString(), and llvm::Align::value().
|
protected |
Definition at line 535 of file RuntimeDyld.cpp.
References Align, llvm::alignTo(), llvm::computeAllocationSizeForSections(), E, I, llvm::isReadOnlyData(), llvm::isRequiredForExecution(), llvm::isTLS(), llvm::max(), llvm::object::ObjectFile::section_begin(), llvm::object::ObjectFile::section_end(), llvm::COFF::SectionSize, llvm::object::BasicSymbolRef::SF_Common, SI, llvm::Error::success(), llvm::object::SymbolicFile::symbol_begin(), llvm::object::SymbolicFile::symbol_end(), and llvm::Expected< T >::takeError().
|
protected |
Emits long jump instruction to Addr.
Definition at line 970 of file RuntimeDyld.cpp.
References llvm::Triple::aarch64, llvm::Triple::aarch64_32, llvm::Triple::aarch64_be, Addr, llvm::Triple::arm, llvm::Triple::armeb, llvm::ELF::EF_MIPS_ARCH, llvm::ELF::EF_MIPS_ARCH_32R6, llvm::ELF::EF_MIPS_ARCH_64R6, llvm::Triple::ppc64, llvm::Triple::ppc64le, llvm::Triple::systemz, llvm::Triple::x86, and llvm::Triple::x86_64.
Referenced by llvm::RuntimeDyldCOFFX86_64::generateRelocationStub(), and llvm::RuntimeDyldELF::processRelocationRef().
void llvm::RuntimeDyldImpl::deregisterEHFrames | ( | ) |
Definition at line 76 of file RuntimeDyld.cpp.
|
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 745 of file RuntimeDyld.cpp.
References Addr, Align, llvm::dbgs(), llvm::format(), LLVM_DEBUG, move, llvm::offsetToAlignment(), llvm::report_fatal_error(), and llvm::Error::success().
|
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 801 of file RuntimeDyld.cpp.
References Addr, llvm::StringRef::data(), llvm::dbgs(), E, llvm::format(), llvm::isReadOnlyData(), llvm::isRequiredForExecution(), llvm::isTLS(), llvm::isZeroInit(), LLVM_DEBUG, llvm::max(), memcpy(), llvm::report_fatal_error(), llvm::Expected< T >::takeError(), and llvm::Align::value().
|
static |
Copy the result into a StringMap, where the keys are held by value.
Definition at line 1217 of file RuntimeDyld.cpp.
References assert(), llvm::inconvertibleErrorCode(), Info, move, llvm::RISCVFenceField::O, llvm::Error::success(), and This.
|
inlinevirtual |
Reimplemented in llvm::RuntimeDyldELF, llvm::RuntimeDyldMachOCRTPBase< Impl >, and llvm::RuntimeDyldCOFFX86_64.
Definition at line 580 of file RuntimeDyldImpl.h.
References llvm::Error::success().
|
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 927 of file RuntimeDyld.cpp.
References i.
Referenced by llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), and llvm::RuntimeDyldELF::processRelocationRef().
|
inline |
Definition at line 568 of file RuntimeDyldImpl.h.
|
inlineprotectedvirtual |
Reimplemented in llvm::RuntimeDyldELF.
Definition at line 436 of file RuntimeDyldImpl.h.
|
protectedvirtual |
Generate JITSymbolFlags from a libObject symbol.
Reimplemented in llvm::RuntimeDyldMachOARM.
Definition at line 741 of file RuntimeDyld.cpp.
References llvm::JITSymbolFlags::fromObjectSymbol().
Referenced by llvm::RuntimeDyldMachOARM::getJITSymbolFlags().
|
protectedpure virtual |
|
inline |
Definition at line 475 of file RuntimeDyldImpl.h.
|
inline |
Definition at line 482 of file RuntimeDyldImpl.h.
|
inline |
Definition at line 468 of file RuntimeDyldImpl.h.
|
protectedpure virtual |
|
inline |
Definition at line 511 of file RuntimeDyldImpl.h.
References llvm::StringMap< ValueTy, AllocatorTy >::end(), and llvm::StringMap< ValueTy, AllocatorTy >::find().
|
inline |
Definition at line 491 of file RuntimeDyldImpl.h.
References llvm::StringMap< ValueTy, AllocatorTy >::end(), and llvm::StringMap< ValueTy, AllocatorTy >::find().
|
inline |
Definition at line 504 of file RuntimeDyldImpl.h.
References llvm::StringMap< ValueTy, AllocatorTy >::end(), and llvm::StringMap< ValueTy, AllocatorTy >::find().
|
inline |
Definition at line 531 of file RuntimeDyldImpl.h.
|
inline |
Definition at line 562 of file RuntimeDyldImpl.h.
|
pure virtual |
Implemented in llvm::RuntimeDyldELF, llvm::RuntimeDyldMachO, and llvm::RuntimeDyldCOFF.
|
pure virtual |
Implemented in llvm::RuntimeDyldCOFF, llvm::RuntimeDyldELF, and llvm::RuntimeDyldMachO.
|
protected |
Definition at line 182 of file RuntimeDyld.cpp.
References llvm::object::ObjectFile::getArch(), and llvm::object::Binary::isLittleEndian().
Referenced by llvm::RuntimeDyldELF::loadObject().
Definition at line 160 of file RuntimeDyld.cpp.
References llvm::numbers::e, i, and llvm_unreachable.
|
inlineprotectedvirtual |
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 355 of file RuntimeDyldImpl.h.
References Addr.
|
inlineprotectedvirtual |
Definition at line 440 of file RuntimeDyldImpl.h.
|
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).
Implemented in llvm::RuntimeDyldELF, llvm::RuntimeDyldMachOAArch64, llvm::RuntimeDyldMachOARM, llvm::RuntimeDyldMachOI386, llvm::RuntimeDyldMachOX86_64, llvm::RuntimeDyldCOFFX86_64, llvm::RuntimeDyldCOFFAArch64, llvm::RuntimeDyldCOFFThumb, and llvm::RuntimeDyldCOFFI386.
|
protected |
Endian-aware read Read the least significant Size bytes from Src.
Definition at line 710 of file RuntimeDyld.cpp.
Referenced by llvm::RuntimeDyldMachOARM::decodeAddend(), llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), llvm::RuntimeDyldELF::processRelocationRef(), and llvm::RuntimeDyldMachOARM::resolveRelocation().
void llvm::RuntimeDyldImpl::reassignSectionAddress | ( | unsigned | SectionID, |
uint64_t | Addr | ||
) |
Definition at line 1078 of file RuntimeDyld.cpp.
References Addr, llvm::dbgs(), llvm::format(), getName(), and LLVM_DEBUG.
|
virtual |
Reimplemented in llvm::RuntimeDyldCOFFAArch64, llvm::RuntimeDyldCOFFThumb, llvm::RuntimeDyldCOFFX86_64, llvm::RuntimeDyldELF, llvm::RuntimeDyldCOFFI386, llvm::RuntimeDyldMachOCRTPBase< Impl >, llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOAArch64 >, llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOI386 >, llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOARM >, and llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOX86_64 >.
Definition at line 74 of file RuntimeDyld.cpp.
|
inlineprotectedvirtual |
Definition at line 443 of file RuntimeDyldImpl.h.
|
inlineprotectedvirtual |
Definition at line 448 of file RuntimeDyldImpl.h.
|
protected |
Resolve relocations to external symbols.
Definition at line 1161 of file RuntimeDyld.cpp.
References assert(), llvm::StringMap< ValueTy, AllocatorTy >::insert(), move, and llvm::Error::success().
void llvm::RuntimeDyldImpl::resolveLocalRelocations | ( | ) |
Definition at line 145 of file RuntimeDyld.cpp.
References Addr, llvm::dbgs(), llvm::format(), and LLVM_DEBUG.
|
protectedpure 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::RuntimeDyldCOFFAArch64, llvm::RuntimeDyldELF, llvm::RuntimeDyldMachOARM, llvm::RuntimeDyldCOFFThumb, llvm::RuntimeDyldCOFFI386, llvm::RuntimeDyldMachOI386, llvm::RuntimeDyldCOFFX86_64, llvm::RuntimeDyldMachOX86_64, and llvm::RuntimeDyldELFMips.
|
protected |
Resolves relocations from Relocs list with address from Value.
Definition at line 1098 of file RuntimeDyld.cpp.
References llvm::numbers::e, i, llvm::object::resolveRelocation(), and llvm::RelocationEntry::SectionID.
void llvm::RuntimeDyldImpl::resolveRelocations | ( | ) |
Definition at line 121 of file RuntimeDyld.cpp.
References llvm::dumpSectionMemory(), LLVM_DEBUG, and S.
|
inlineprotectedvirtual |
Definition at line 335 of file RuntimeDyldImpl.h.
|
inline |
Definition at line 572 of file RuntimeDyldImpl.h.
References move.
|
inline |
Definition at line 461 of file RuntimeDyldImpl.h.
|
protected |
Endian-aware write.
Write the least significant Size bytes from Value to Dst.
Definition at line 724 of file RuntimeDyld.cpp.
Referenced by llvm::RuntimeDyldMachOX86_64::resolveRelocation(), llvm::RuntimeDyldCOFFX86_64::resolveRelocation(), llvm::RuntimeDyldMachOI386::resolveRelocation(), llvm::RuntimeDyldCOFFI386::resolveRelocation(), llvm::RuntimeDyldCOFFThumb::resolveRelocation(), llvm::RuntimeDyldMachOARM::resolveRelocation(), and llvm::RuntimeDyldMachOAArch64::resolveRelocation().
|
inlineprotected |
Definition at line 320 of file RuntimeDyldImpl.h.
References Addr, llvm::support::big, and llvm::support::little.
|
inlineprotected |
Definition at line 325 of file RuntimeDyldImpl.h.
References Addr, llvm::support::big, and llvm::support::little.
|
inlineprotected |
Definition at line 330 of file RuntimeDyldImpl.h.
References Addr, llvm::support::big, and llvm::support::little.
|
friend |
Definition at line 239 of file RuntimeDyldImpl.h.
|
staticprotected |
Definition at line 241 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 288 of file RuntimeDyldImpl.h.
Referenced by llvm::RuntimeDyldELF::create(), llvm::RuntimeDyldELF::getGOTEntrySize(), and llvm::RuntimeDyldELF::processRelocationRef().
|
protected |
Definition at line 318 of file RuntimeDyldImpl.h.
Referenced by llvm::RuntimeDyldELF::loadObject().
|
protected |
Definition at line 283 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 264 of file RuntimeDyldImpl.h.
Referenced by llvm::RuntimeDyldMachOARM::isAddrTargetThumb(), llvm::RuntimeDyldMachOARM::processRelocationRef(), and llvm::RuntimeDyldELF::processRelocationRef().
|
protected |
Definition at line 317 of file RuntimeDyldImpl.h.
Referenced by llvm::RuntimeDyldELF::loadObject().
|
protected |
Definition at line 291 of file RuntimeDyldImpl.h.
Referenced by llvm::RuntimeDyldELF::finalizeLoad(), llvm::RuntimeDyldELF::getGOTEntrySize(), llvm::RuntimeDyldELF::processRelocationRef(), and llvm::RuntimeDyldELFMips::resolveRelocation().
|
protected |
Definition at line 292 of file RuntimeDyldImpl.h.
Referenced by llvm::RuntimeDyldELF::finalizeLoad(), llvm::RuntimeDyldELF::getGOTEntrySize(), llvm::RuntimeDyldELF::processRelocationRef(), and llvm::RuntimeDyldELFMips::resolveRelocation().
|
protected |
Definition at line 290 of file RuntimeDyldImpl.h.
Referenced by llvm::RuntimeDyldELF::finalizeLoad(), llvm::RuntimeDyldELF::getGOTEntrySize(), llvm::RuntimeDyldELF::processRelocationRef(), and llvm::RuntimeDyldELFMips::resolveRelocation().
|
protected |
Definition at line 289 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 308 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 244 of file RuntimeDyldImpl.h.
Referenced by llvm::RuntimeDyldELF::create(), llvm::RuntimeDyldELF::finalizeLoad(), llvm::RuntimeDyldELF::processRelocationRef(), llvm::RuntimeDyldELF::registerEHFrames(), and llvm::RuntimeDyldCOFFX86_64::registerEHFrames().
|
protected |
Definition at line 312 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 296 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 278 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 247 of file RuntimeDyldImpl.h.
|
protected |
Definition at line 254 of file RuntimeDyldImpl.h.
Referenced by llvm::RuntimeDyldMachOAArch64::decodeAddend(), llvm::RuntimeDyldMachOARM::decodeAddend(), llvm::RuntimeDyldELF::finalizeLoad(), llvm::RuntimeDyldCOFFX86_64::generateRelocationStub(), llvm::RuntimeDyldMachOARM::isAddrTargetThumb(), llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), llvm::RuntimeDyldELF::processRelocationRef(), llvm::RuntimeDyldELF::registerEHFrames(), llvm::RuntimeDyldCOFFX86_64::registerEHFrames(), llvm::RuntimeDyldELFMips::resolveRelocation(), llvm::RuntimeDyldMachOX86_64::resolveRelocation(), llvm::RuntimeDyldCOFFX86_64::resolveRelocation(), llvm::RuntimeDyldMachOI386::resolveRelocation(), llvm::RuntimeDyldCOFFI386::resolveRelocation(), llvm::RuntimeDyldCOFFThumb::resolveRelocation(), llvm::RuntimeDyldMachOARM::resolveRelocation(), llvm::RuntimeDyldELF::resolveRelocation(), and llvm::RuntimeDyldMachOAArch64::resolveRelocation().