LLVM 19.0.0git
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::RuntimeDyldELF Class Reference

#include "ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h"

Inheritance diagram for llvm::RuntimeDyldELF:
Inheritance graph
[legend]

Public Member Functions

 RuntimeDyldELF (RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
 
 ~RuntimeDyldELF () override
 
std::unique_ptr< RuntimeDyld::LoadedObjectInfoloadObject (const object::ObjectFile &O) override
 
void resolveRelocation (const RelocationEntry &RE, uint64_t Value) override
 A object file specific relocation resolver.
 
Expected< relocation_iteratorprocessRelocationRef (unsigned SectionID, relocation_iterator RelI, const ObjectFile &Obj, ObjSectionToIDMap &ObjSectionToID, StubMap &Stubs) override
 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).
 
bool isCompatibleFile (const object::ObjectFile &Obj) const override
 
void registerEHFrames () override
 
Error finalizeLoad (const ObjectFile &Obj, ObjSectionToIDMap &SectionMap) override
 
- Public Member Functions inherited from llvm::RuntimeDyldImpl
 RuntimeDyldImpl (RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
 
virtual ~RuntimeDyldImpl ()
 
void setProcessAllSections (bool ProcessAllSections)
 
virtual std::unique_ptr< RuntimeDyld::LoadedObjectInfoloadObject (const object::ObjectFile &Obj)=0
 
uint64_t getSectionLoadAddress (unsigned SectionID) const
 
uint8_t * getSectionAddress (unsigned SectionID) const
 
StringRef getSectionContent (unsigned SectionID) const
 
uint8_t * getSymbolLocalAddress (StringRef Name) const
 
unsigned getSymbolSectionID (StringRef Name) const
 
JITEvaluatedSymbol getSymbol (StringRef Name) const
 
std::map< StringRef, JITEvaluatedSymbolgetSymbolTable () const
 
void resolveRelocations ()
 
void resolveLocalRelocations ()
 
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
 
void setNotifyStubEmitted (NotifyStubEmittedFunction NotifyStubEmitted)
 
virtual void registerEHFrames ()
 
void deregisterEHFrames ()
 
virtual Error finalizeLoad (const ObjectFile &ObjImg, ObjSectionToIDMap &SectionMap)
 

Static Public Member Functions

static std::unique_ptr< RuntimeDyldELFcreate (Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
 
- 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

size_t getGOTEntrySize () override
 
- 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< JITSymbolFlagsgetJITSymbolFlags (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< unsignedemitSection (const ObjectFile &Obj, const SectionRef &Section, bool IsCode)
 Emits section data from the object file to the MemoryManager.
 
Expected< unsignedfindOrEmitSection (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_iteratorprocessRelocationRef (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< ObjSectionToIDMaploadObjectImpl (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

DenseMap< SID, SIDSectionToGOTMap
 
- Protected Attributes inherited from llvm::RuntimeDyldImpl
RuntimeDyld::MemoryManagerMemMgr
 
JITSymbolResolverResolver
 
SectionList Sections
 
RTDyldSymbolTable GlobalSymbolTable
 
std::unordered_map< unsigned, RelocationListRelocations
 
StringMap< RelocationListExternalSymbolRelocations
 
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< SectionEntrySectionList
 
typedef unsigned SID
 
typedef std::map< SectionRef, unsignedObjSectionToIDMap
 
typedef std::vector< SymbolRefCommonSymbolList
 
typedef SmallVector< RelocationEntry, 64 > RelocationList
 
typedef std::map< RelocationValueRef, uintptr_t > StubMap
 
using NotifyStubEmittedFunction = RuntimeDyld::NotifyStubEmittedFunction
 
- Static Protected Attributes inherited from llvm::RuntimeDyldImpl
static const unsigned AbsoluteSymbolSection = ~0U
 

Detailed Description

Definition at line 26 of file RuntimeDyldELF.h.

Constructor & Destructor Documentation

◆ RuntimeDyldELF()

llvm::RuntimeDyldELF::RuntimeDyldELF ( RuntimeDyld::MemoryManager MemMgr,
JITSymbolResolver Resolver 
)

Definition at line 217 of file RuntimeDyldELF.cpp.

◆ ~RuntimeDyldELF()

llvm::RuntimeDyldELF::~RuntimeDyldELF ( )
overridedefault

Member Function Documentation

◆ create()

std::unique_ptr< RuntimeDyldELF > llvm::RuntimeDyldELF::create ( Triple::ArchType  Arch,
RuntimeDyld::MemoryManager MemMgr,
JITSymbolResolver Resolver 
)
static

◆ finalizeLoad()

Error llvm::RuntimeDyldELF::finalizeLoad ( const ObjectFile Obj,
ObjSectionToIDMap SectionMap 
)
overridevirtual

◆ getGOTEntrySize()

size_t llvm::RuntimeDyldELF::getGOTEntrySize ( )
overrideprotectedvirtual

◆ isCompatibleFile()

bool llvm::RuntimeDyldELF::isCompatibleFile ( const object::ObjectFile Obj) const
overridevirtual

Implements llvm::RuntimeDyldImpl.

Definition at line 2421 of file RuntimeDyldELF.cpp.

References llvm::object::Binary::isELF().

◆ loadObject()

std::unique_ptr< RuntimeDyld::LoadedObjectInfo > llvm::RuntimeDyldELF::loadObject ( const object::ObjectFile O)
overridevirtual

◆ processRelocationRef()

Expected< relocation_iterator > llvm::RuntimeDyldELF::processRelocationRef ( unsigned  SectionID,
relocation_iterator  RelI,
const ObjectFile Obj,
ObjSectionToIDMap ObjSectionToID,
StubMap Stubs 
)
overridevirtual

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.

Implements llvm::RuntimeDyldImpl.

Definition at line 1218 of file RuntimeDyldELF.cpp.

References llvm::Triple::aarch64, llvm::Triple::aarch64_be, llvm::RelocationEntry::Addend, llvm::RelocationValueRef::Addend, llvm::RuntimeDyldImpl::addRelocationForSection(), llvm::RuntimeDyldImpl::addRelocationForSymbol(), llvm::alignTo(), llvm::RuntimeDyld::MemoryManager::allowStubAllocation(), llvm::RuntimeDyldImpl::Arch, llvm::Triple::arm, llvm::consumeError(), llvm::RuntimeDyldImpl::createStubFunction(), llvm::StringRef::data(), llvm::dbgs(), llvm::ELF::decodePPC64LocalEntryOffset(), llvm::ELF::EF_PPC64_ABI, llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::StringMap< ValueTy, AllocatorTy >::find(), llvm::RuntimeDyldImpl::findOrEmitSection(), llvm::object::ELFRelocationRef::getAddend(), llvm::object::ELFObjectFileBase::getPlatformFlags(), llvm::RuntimeDyldImpl::GlobalSymbolTable, I, llvm::RuntimeDyldImpl::IsMipsN32ABI, llvm::RuntimeDyldImpl::IsMipsN64ABI, llvm::RuntimeDyldImpl::IsMipsO32ABI, llvm::RuntimeDyldImpl::IsTargetLittleEndian, llvm::object::SectionRef::isText(), LLVM_DEBUG, llvm_unreachable, llvm::logAllUnhandledErrors(), llvm::RuntimeDyldImpl::MemMgr, llvm::Offset, OS, llvm::Triple::ppc64, llvm::Triple::ppc64le, llvm::RuntimeDyldImpl::readBytesUnaligned(), llvm::RelocationEntry::RelType, llvm::report_fatal_error(), llvm::object::ObjectFile::section_end(), llvm::RelocationEntry::SectionID, llvm::RelocationValueRef::SectionID, llvm::RuntimeDyldImpl::Sections, llvm::object::SymbolRef::ST_Data, llvm::object::SymbolRef::ST_Debug, llvm::object::SymbolRef::ST_Function, llvm::object::SymbolRef::ST_Other, llvm::object::SymbolRef::ST_Unknown, llvm::object::SymbolicFile::symbol_end(), llvm::RelocationEntry::SymOffset, llvm::Triple::systemz, llvm::Expected< T >::takeError(), llvm::RuntimeDyldImpl::writeInt32BE(), llvm::Triple::x86, and llvm::Triple::x86_64.

◆ registerEHFrames()

void llvm::RuntimeDyldELF::registerEHFrames ( )
overridevirtual

◆ resolveRelocation()

void llvm::RuntimeDyldELF::resolveRelocation ( const RelocationEntry RE,
uint64_t  Value 
)
overridevirtual

A object file specific relocation resolver.

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

Implements llvm::RuntimeDyldImpl.

Reimplemented in llvm::RuntimeDyldELFMips.

Definition at line 1035 of file RuntimeDyldELF.cpp.

References llvm::RelocationEntry::Addend, llvm::RelocationEntry::Offset, llvm::RelocationEntry::RelType, llvm::RelocationEntry::SectionID, llvm::RuntimeDyldImpl::Sections, and llvm::RelocationEntry::SymOffset.

Member Data Documentation

◆ SectionToGOTMap

DenseMap<SID, SID> llvm::RuntimeDyldELF::SectionToGOTMap
protected

Definition at line 143 of file RuntimeDyldELF.h.

Referenced by finalizeLoad().


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