LLVM  6.0.0svn
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
llvm::RuntimeDyldMachO Class Reference

#include "ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h"

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

Classes

struct  EHFrameRelatedSections
 
struct  SectionOffsetPair
 

Public Member Functions

std::unique_ptr< RuntimeDyld::LoadedObjectInfoloadObject (const object::ObjectFile &O) override
 
SectionEntrygetSection (unsigned SectionID)
 
bool isCompatibleFile (const object::ObjectFile &Obj) const override
 
- Public Member Functions inherited from llvm::RuntimeDyldImpl
 RuntimeDyldImpl (RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
 
virtual ~RuntimeDyldImpl ()
 
void setProcessAllSections (bool ProcessAllSections)
 
void setRuntimeDyldChecker (RuntimeDyldCheckerImpl *Checker)
 
uint8_t * getSymbolLocalAddress (StringRef Name) const
 
JITEvaluatedSymbol 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 void registerEHFrames ()
 
void deregisterEHFrames ()
 
virtual Error finalizeLoad (const ObjectFile &ObjImg, ObjSectionToIDMap &SectionMap)
 

Static Public Member Functions

static std::unique_ptr< RuntimeDyldMachOcreate (Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
 Create a RuntimeDyldMachO instance for the given target architecture. More...
 

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). More...
 
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. More...
 
Expected< relocation_iteratorprocessScatteredVANILLA (unsigned SectionID, relocation_iterator RelI, const ObjectFile &BaseObjT, RuntimeDyldMachO::ObjSectionToIDMap &ObjSectionToID, bool TargetIsLocalThumbFunc=false)
 Process a scattered vanilla relocation. More...
 
Expected< RelocationValueRefgetRelocationValueRef (const ObjectFile &BaseTObj, const relocation_iterator &RI, const RelocationEntry &RE, ObjSectionToIDMap &ObjSectionToID)
 Construct a RelocationValueRef representing the relocation target. More...
 
void makeValueAddendPCRel (RelocationValueRef &Value, const relocation_iterator &RI, unsigned OffsetToNextPC)
 Make the RelocationValueRef addend PC-relative. More...
 
void dumpRelocationToResolve (const RelocationEntry &RE, uint64_t Value) const
 Dump information about the relocation entry (RE) and resolved value. More...
 
Error populateIndirectSymbolPointersSection (const MachOObjectFile &Obj, const SectionRef &PTSection, unsigned PTSectionID)
 
- Protected Member Functions inherited from llvm::RuntimeDyldImpl
virtual unsigned getMaxStubSize ()=0
 
virtual unsigned getStubAlignment ()=0
 
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. More...
 
void writeBytesUnaligned (uint64_t Value, uint8_t *Dst, unsigned Size) const
 Endian-aware write. More...
 
virtual JITSymbolFlags getJITSymbolFlags (const BasicSymbolRef &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)
 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< unsignedemitSection (const ObjectFile &Obj, const SectionRef &Section, bool IsCode)
 Emits section data from the object file to the MemoryManager. More...
 
Expected< unsignedfindOrEmitSection (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_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). More...
 
Error resolveExternalSymbols ()
 Resolve relocations to external symbols. More...
 
Error computeTotalAllocSize (const ObjectFile &Obj, uint64_t &CodeSize, uint32_t &CodeAlign, uint64_t &RODataSize, uint32_t &RODataAlign, uint64_t &RWDataSize, uint32_t &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 bool relocationNeedsGot (const RelocationRef &R) const
 
virtual bool relocationNeedsStub (const RelocationRef &R) 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::MemoryManagerMemMgr
 
JITSymbolResolverResolver
 
RuntimeDyldCheckerImplChecker
 
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
 
bool HasError
 
std::string ErrorStr
 

Additional Inherited Members

- Protected Types inherited from llvm::RuntimeDyldImpl
typedef SmallVector< SectionEntry, 64 > SectionList
 
typedef unsigned SID
 
typedef std::map< SectionRef, unsignedObjSectionToIDMap
 
typedef std::vector< SymbolRefCommonSymbolList
 
typedef SmallVector< RelocationEntry, 64 > RelocationList
 
typedef std::map< RelocationValueRef, uintptr_t > StubMap
 
- Static Protected Attributes inherited from llvm::RuntimeDyldImpl
static const unsigned AbsoluteSymbolSection = ~0U
 

Detailed Description

Definition at line 27 of file RuntimeDyldMachO.h.

Constructor & Destructor Documentation

◆ RuntimeDyldMachO()

llvm::RuntimeDyldMachO::RuntimeDyldMachO ( RuntimeDyld::MemoryManager MemMgr,
JITSymbolResolver Resolver 
)
inlineprotected

Definition at line 52 of file RuntimeDyldMachO.h.

Member Function Documentation

◆ create()

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

Create a RuntimeDyldMachO instance for the given target architecture.

Definition at line 347 of file RuntimeDyldMachO.cpp.

References llvm::Triple::aarch64, llvm::Triple::arm, llvm_unreachable, llvm::Triple::x86, and llvm::Triple::x86_64.

Referenced by llvm::createRuntimeDyldMachO().

◆ dumpRelocationToResolve()

void llvm::RuntimeDyldMachO::dumpRelocationToResolve ( const RelocationEntry RE,
uint64_t  Value 
) const
protected

◆ getRelocationEntry()

RelocationEntry llvm::RuntimeDyldMachO::getRelocationEntry ( unsigned  SectionID,
const ObjectFile BaseTObj,
const relocation_iterator RI 
) const
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 65 of file RuntimeDyldMachO.h.

References llvm::object::MachOObjectFile::getAnyRelocationLength(), llvm::object::MachOObjectFile::getAnyRelocationPCRel(), llvm::object::MachOObjectFile::getAnyRelocationType(), llvm::object::MachOObjectFile::getRelocation(), llvm::RISCVFenceField::O, and llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Size.

Referenced by llvm::RuntimeDyldMachOI386::processRelocationRef(), llvm::RuntimeDyldMachOX86_64::processRelocationRef(), llvm::RuntimeDyldMachOARM::processRelocationRef(), and llvm::RuntimeDyldMachOAArch64::processRelocationRef().

◆ getRelocationValueRef()

Expected< RelocationValueRef > llvm::RuntimeDyldMachO::getRelocationValueRef ( const ObjectFile BaseTObj,
const relocation_iterator RI,
const RelocationEntry RE,
ObjSectionToIDMap ObjSectionToID 
)
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 98 of file RuntimeDyldMachO.cpp.

References llvm::RelocationEntry::Addend, llvm::StringRef::data(), llvm::object::SectionRef::getAddress(), llvm::object::MachOObjectFile::getAnyRelocationSection(), llvm::object::SymbolRef::getName(), llvm::object::MachOObjectFile::getPlainRelocationExternal(), llvm::object::MachOObjectFile::getRelocation(), llvm::object::SectionRef::isText(), llvm::RelocationValueRef::Offset, llvm::RelocationValueRef::SectionID, SI, llvm::ARMBuildAttrs::Symbol, and llvm::RelocationValueRef::SymbolName.

Referenced by llvm::RuntimeDyldMachOI386::processRelocationRef(), llvm::RuntimeDyldMachOX86_64::processRelocationRef(), llvm::RuntimeDyldMachOARM::processRelocationRef(), and llvm::RuntimeDyldMachOAArch64::processRelocationRef().

◆ getSection()

SectionEntry& llvm::RuntimeDyldMachO::getSection ( unsigned  SectionID)
inline

Definition at line 133 of file RuntimeDyldMachO.h.

◆ getSectionByAddress()

section_iterator llvm::RuntimeDyldMachO::getSectionByAddress ( const MachOObjectFile Obj,
uint64_t  Addr 
)
staticprotected

◆ isCompatibleFile()

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

Implements llvm::RuntimeDyldImpl.

Definition at line 223 of file RuntimeDyldMachO.cpp.

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

◆ loadObject()

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

Implements llvm::RuntimeDyldImpl.

Definition at line 366 of file RuntimeDyldMachO.cpp.

References llvm::logAllUnhandledErrors().

◆ makeValueAddendPCRel()

void llvm::RuntimeDyldMachO::makeValueAddendPCRel ( RelocationValueRef Value,
const relocation_iterator RI,
unsigned  OffsetToNextPC 
)
protected

◆ memcpyAddend()

int64_t llvm::RuntimeDyldMachO::memcpyAddend ( const RelocationEntry RE) const
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 47 of file RuntimeDyldMachO.cpp.

References llvm::RelocationEntry::Offset, llvm::RelocationEntry::SectionID, and llvm::RelocationEntry::Size.

Referenced by llvm::RuntimeDyldMachOARM::decodeAddend(), llvm::RuntimeDyldMachOX86_64::processRelocationRef(), and llvm::RuntimeDyldMachOI386::processRelocationRef().

◆ populateIndirectSymbolPointersSection()

Error llvm::RuntimeDyldMachO::populateIndirectSymbolPointersSection ( const MachOObjectFile Obj,
const SectionRef PTSection,
unsigned  PTSectionID 
)
protected

◆ processScatteredVANILLA()

Expected< relocation_iterator > llvm::RuntimeDyldMachO::processScatteredVANILLA ( unsigned  SectionID,
relocation_iterator  RelI,
const ObjectFile BaseObjT,
RuntimeDyldMachO::ObjSectionToIDMap ObjSectionToID,
bool  TargetIsLocalThumbFunc = false 
)
protected

Member Data Documentation

◆ UnregisteredEHFrameSections

SmallVector<EHFrameRelatedSections, 2> llvm::RuntimeDyldMachO::UnregisteredEHFrameSections
protected

Definition at line 50 of file RuntimeDyldMachO.h.


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