|
LLVM 22.0.0git
|
#include "ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h"
Classes | |
| struct | EHFrameRelatedSections |
| struct | SectionOffsetPair |
Static Public Member Functions | |
| static std::unique_ptr< RuntimeDyldMachO > | create (Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver) |
| Create a RuntimeDyldMachO instance for the given target architecture. | |
| Static Public Member Functions inherited from llvm::RuntimeDyldImpl | |
| 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 Member Functions | |
| RuntimeDyldMachO (RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver) | |
| int64_t | memcpyAddend (const RelocationEntry &RE) const |
| This convenience method uses memcpy to extract a contiguous addend (the addend size and offset are taken from the corresponding fields of the RE). | |
| RelocationEntry | getRelocationEntry (unsigned SectionID, const ObjectFile &BaseTObj, const relocation_iterator &RI) const |
| Given a relocation_iterator for a non-scattered relocation, construct a RelocationEntry and fill in the common fields. | |
| Expected< relocation_iterator > | processScatteredVANILLA (unsigned SectionID, relocation_iterator RelI, const ObjectFile &BaseObjT, RuntimeDyldMachO::ObjSectionToIDMap &ObjSectionToID, bool TargetIsLocalThumbFunc=false) |
| Process a scattered vanilla relocation. | |
| Expected< RelocationValueRef > | getRelocationValueRef (const ObjectFile &BaseTObj, const relocation_iterator &RI, const RelocationEntry &RE, ObjSectionToIDMap &ObjSectionToID) |
| Construct a RelocationValueRef representing the relocation target. | |
| void | makeValueAddendPCRel (RelocationValueRef &Value, const relocation_iterator &RI, unsigned OffsetToNextPC) |
| Make the RelocationValueRef addend PC-relative. | |
| void | dumpRelocationToResolve (const RelocationEntry &RE, uint64_t Value) const |
| Dump information about the relocation entry (RE) and resolved value. | |
| Error | populateIndirectSymbolPointersSection (const MachOObjectFile &Obj, const SectionRef &PTSection, unsigned PTSectionID) |
| Protected Member Functions inherited from llvm::RuntimeDyldImpl | |
| 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. | |
| void | writeBytesUnaligned (uint64_t Value, uint8_t *Dst, unsigned Size) const |
| Endian-aware write. | |
| virtual Expected< JITSymbolFlags > | getJITSymbolFlags (const SymbolRef &Sym) |
| Generate JITSymbolFlags from a libObject symbol. | |
| virtual uint64_t | modifyAddressBasedOnFlags (uint64_t Addr, JITSymbolFlags Flags) const |
| Modify the given target address based on the given symbol flags. | |
| 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. | |
| Expected< unsigned > | emitSection (const ObjectFile &Obj, const SectionRef &Section, bool IsCode) |
| Emits section data from the object file to the MemoryManager. | |
| Expected< 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 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). | |
| void | applyExternalSymbolRelocations (const StringMap< JITEvaluatedSymbol > ExternalSymbolMap) |
| Error | resolveExternalSymbols () |
| Resolve relocations to external symbols. | |
| 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 |
| virtual bool | relocationNeedsDLLImportStub (const RelocationRef &R) const |
| virtual unsigned | sizeAfterAddingDLLImportStub (unsigned Size) const |
Static Protected Member Functions | |
| static section_iterator | getSectionByAddress (const MachOObjectFile &Obj, uint64_t Addr) |
Protected Attributes | |
| SmallVector< EHFrameRelatedSections, 2 > | UnregisteredEHFrameSections |
| Protected Attributes inherited from llvm::RuntimeDyldImpl | |
| 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 |
Additional Inherited Members | |
| Protected Types inherited from llvm::RuntimeDyldImpl | |
| 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 |
| Static Protected Attributes inherited from llvm::RuntimeDyldImpl | |
| static const unsigned | AbsoluteSymbolSection = ~0U |
Definition at line 21 of file RuntimeDyldMachO.h.
|
inlineprotected |
Definition at line 46 of file RuntimeDyldMachO.h.
References llvm::RuntimeDyldImpl::MemMgr, llvm::RuntimeDyldImpl::Resolver, and llvm::RuntimeDyldImpl::RuntimeDyldImpl().
Referenced by llvm::RuntimeDyldMachOCRTPBase< RuntimeDyldMachOARM >::RuntimeDyldMachOCRTPBase().
|
static |
Create a RuntimeDyldMachO instance for the given target architecture.
Definition at line 348 of file RuntimeDyldMachO.cpp.
References llvm::Triple::aarch64, llvm::Triple::aarch64_32, llvm::RuntimeDyldImpl::Arch, llvm::Triple::arm, llvm_unreachable, llvm::RuntimeDyldImpl::MemMgr, llvm::RuntimeDyldImpl::Resolver, llvm::Triple::x86, and llvm::Triple::x86_64.
Referenced by llvm::createRuntimeDyldMachO().
|
protected |
Dump information about the relocation entry (RE) and resolved value.
Definition at line 147 of file RuntimeDyldMachO.cpp.
References llvm::RelocationEntry::Offset, llvm::RelocationEntry::SectionID, and llvm::RuntimeDyldImpl::Sections.
Referenced by llvm::RuntimeDyldMachOAArch64::resolveRelocation(), llvm::RuntimeDyldMachOARM::resolveRelocation(), llvm::RuntimeDyldMachOI386::resolveRelocation(), and llvm::RuntimeDyldMachOX86_64::resolveRelocation().
|
inlineprotected |
Given a relocation_iterator for a non-scattered relocation, construct a RelocationEntry and fill in the common fields.
The 'Addend' field is not filled in, since immediate encodings are highly target/opcode specific. For targets/opcodes with simple, contiguous immediates (e.g. X86) the memcpyAddend method can be used to read the immediate.
Definition at line 59 of file RuntimeDyldMachO.h.
References llvm::object::MachOObjectFile::getAnyRelocationLength(), llvm::object::MachOObjectFile::getAnyRelocationPCRel(), llvm::object::MachOObjectFile::getAnyRelocationType(), llvm::object::RelocationRef::getOffset(), llvm::object::RelocationRef::getRawDataRefImpl(), llvm::object::MachOObjectFile::getRelocation(), llvm::Offset, and Size.
Referenced by llvm::RuntimeDyldMachOAArch64::processRelocationRef(), llvm::RuntimeDyldMachOARM::processRelocationRef(), llvm::RuntimeDyldMachOI386::processRelocationRef(), and llvm::RuntimeDyldMachOX86_64::processRelocationRef().
|
protected |
Construct a RelocationValueRef representing the relocation target.
For Symbols in known sections, this will return a RelocationValueRef representing a (SectionID, Offset) pair. For Symbols whose section is not known, this will return a (SymbolName, Offset) pair, where the Offset is taken from the instruction immediate (held in RE.Addend). In both cases the Addend field is NOT fixed up to be PC-relative. That should be done by the caller where appropriate by calling makePCRel on the RelocationValueRef.
Definition at line 96 of file RuntimeDyldMachO.cpp.
References llvm::RelocationEntry::Addend, llvm::StringRef::data(), llvm::RuntimeDyldImpl::findOrEmitSection(), llvm::object::SectionRef::getAddress(), llvm::object::MachOObjectFile::getAnyRelocationSection(), llvm::object::MachOObjectFile::getPlainRelocationExternal(), llvm::object::RelocationRef::getRawDataRefImpl(), llvm::object::MachOObjectFile::getRelocation(), llvm::object::RelocationRef::getSymbol(), llvm::RuntimeDyldImpl::GlobalSymbolTable, and llvm::object::SectionRef::isText().
Referenced by llvm::RuntimeDyldMachOAArch64::processRelocationRef(), llvm::RuntimeDyldMachOARM::processRelocationRef(), llvm::RuntimeDyldMachOI386::processRelocationRef(), and llvm::RuntimeDyldMachOX86_64::processRelocationRef().
|
inline |
Definition at line 127 of file RuntimeDyldMachO.h.
References llvm::RuntimeDyldImpl::Sections.
|
staticprotected |
Definition at line 162 of file RuntimeDyldMachO.cpp.
References llvm::object::MachOObjectFile::section_begin(), and llvm::object::MachOObjectFile::section_end().
Referenced by processScatteredVANILLA().
|
overridevirtual |
Implements llvm::RuntimeDyldImpl.
Definition at line 221 of file RuntimeDyldMachO.cpp.
References llvm::object::Binary::isMachO().
|
overridevirtual |
Implements llvm::RuntimeDyldImpl.
Definition at line 369 of file RuntimeDyldMachO.cpp.
References llvm::RuntimeDyldImpl::ErrorStr, llvm::RuntimeDyldImpl::HasError, llvm::RuntimeDyldImpl::loadObjectImpl(), and llvm::logAllUnhandledErrors().
|
protected |
Make the RelocationValueRef addend PC-relative.
Definition at line 139 of file RuntimeDyldMachO.cpp.
References llvm::cast(), llvm::object::SectionRef::getAddress(), llvm::object::RelocationRef::getObject(), and llvm::object::RelocationRef::getOffset().
Referenced by llvm::RuntimeDyldMachOAArch64::processRelocationRef(), llvm::RuntimeDyldMachOARM::processRelocationRef(), llvm::RuntimeDyldMachOI386::processRelocationRef(), and llvm::RuntimeDyldMachOX86_64::processRelocationRef().
|
protected |
This convenience method uses memcpy to extract a contiguous addend (the addend size and offset are taken from the corresponding fields of the RE).
Definition at line 45 of file RuntimeDyldMachO.cpp.
References llvm::RelocationEntry::Offset, llvm::RuntimeDyldImpl::readBytesUnaligned(), llvm::RelocationEntry::SectionID, llvm::RuntimeDyldImpl::Sections, and llvm::RelocationEntry::Size.
Referenced by llvm::RuntimeDyldMachOARM::decodeAddend(), llvm::RuntimeDyldMachOI386::processRelocationRef(), and llvm::RuntimeDyldMachOX86_64::processRelocationRef().
|
protected |
Definition at line 179 of file RuntimeDyldMachO.cpp.
References llvm::RuntimeDyldImpl::addRelocationForSymbol(), assert(), llvm::dbgs(), llvm::MachO::GENERIC_RELOC_VANILLA, llvm::object::MachOObjectFile::getDysymtabLoadCommand(), llvm::object::MachOObjectFile::getIndirectSymbolTableEntry(), getName(), llvm::object::SectionRef::getRawDataRefImpl(), llvm::object::MachOObjectFile::getSection(), llvm::object::MachOObjectFile::getSymbolByIndex(), llvm::object::MachOObjectFile::is64Bit(), LLVM_DEBUG, llvm::MachO::section::reserved1, llvm::RuntimeDyldImpl::Sections, llvm::MachO::section::size, and llvm::Error::success().
Referenced by llvm::RuntimeDyldMachOARM::finalizeSection(), and llvm::RuntimeDyldMachOI386::finalizeSection().
|
protected |
Process a scattered vanilla relocation.
Definition at line 53 of file RuntimeDyldMachO.cpp.
References llvm::RuntimeDyldImpl::addRelocationForSection(), assert(), llvm::RuntimeDyldImpl::findOrEmitSection(), llvm::object::SectionRef::getAddress(), llvm::object::MachOObjectFile::getAnyRelocationLength(), llvm::object::MachOObjectFile::getAnyRelocationPCRel(), llvm::object::MachOObjectFile::getAnyRelocationType(), llvm::object::RelocationRef::getOffset(), llvm::object::RelocationRef::getRawDataRefImpl(), llvm::object::MachOObjectFile::getRelocation(), llvm::object::MachOObjectFile::getScatteredRelocationValue(), getSectionByAddress(), llvm::object::SectionRef::isText(), llvm::Offset, llvm::RuntimeDyldImpl::readBytesUnaligned(), llvm::object::MachOObjectFile::section_end(), llvm::RuntimeDyldImpl::Sections, and Size.
Referenced by llvm::RuntimeDyldMachOARM::processRelocationRef(), and llvm::RuntimeDyldMachOI386::processRelocationRef().
|
protected |
Definition at line 44 of file RuntimeDyldMachO.h.
Referenced by llvm::RuntimeDyldMachOCRTPBase< Impl >::finalizeLoad(), and llvm::RuntimeDyldMachOCRTPBase< Impl >::registerEHFrames().