13#ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
14#define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
31#include <system_error>
37template <
typename T>
class OwningBinary;
51 std::error_code convertToErrorCode()
const override;
67 unsigned SectionID,
uint32_t StubOffset)>;
77 : RTDyld(RTDyld), ObjSecToIDMap(
std::
move(ObjSecToIDMap)) {}
86 virtual void anchor();
114 bool IsReadOnly) = 0;
126 virtual TLSSection allocateTLSSection(uintptr_t
Size,
unsigned Alignment,
139 uintptr_t RODataSize,
Align RODataAlign,
140 uintptr_t RWDataSize,
141 Align RWDataAlign) {}
187 virtual void anchor();
189 bool FinalizationLocked =
false;
200 LLVM_ABI std::unique_ptr<LoadedObjectInfo>
242 this->NotifyStubEmitted = std::move(NotifyStubEmitted);
266 assert(!Dyld &&
"setProcessAllSections must be called before loadObject.");
267 this->ProcessAllSections = ProcessAllSections;
293 bool ProcessAllSections,
295 std::map<StringRef, JITEvaluatedSymbol>)>
298 std::unique_ptr<LoadedObjectInfo>,
Error)>
303 std::unique_ptr<RuntimeDyldImpl> Dyld;
306 bool ProcessAllSections;
319 bool ProcessAllSections,
322 std::map<StringRef, JITEvaluatedSymbol>)>
325 std::unique_ptr<RuntimeDyld::LoadedObjectInfo>,
Error)>
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Base class for user error types.
Lightweight error class with error context and mandatory checking.
Represents a symbol that has been evaluated to an address already.
Symbol resolution interface.
An inferface for inquiring the load address of a loaded object file to be used by the DIContext imple...
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Base class for errors originating in RuntimeDyld, e.g.
const std::string & getErrorMessage() const
RuntimeDyldError(std::string ErrMsg)
Information about the loaded object.
std::map< object::SectionRef, unsigned > ObjSectionToIDMap
ObjSectionToIDMap ObjSecToIDMap
virtual object::OwningBinary< object::ObjectFile > getObjectForDebug(const object::ObjectFile &Obj) const =0
LoadedObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap)
virtual void reserveAllocationSpace(uintptr_t CodeSize, Align CodeAlign, uintptr_t RODataSize, Align RODataAlign, uintptr_t RWDataSize, Align RWDataAlign)
Inform the memory manager about the total amount of memory required to allocate all sections to be lo...
virtual bool needsToReserveAllocationSpace()
Override to return true to enable the reserveAllocationSpace callback.
virtual void notifyObjectLoaded(RuntimeDyld &RTDyld, const object::ObjectFile &Obj)
This method is called after an object has been loaded into memory but before relocations are applied ...
virtual uint8_t * allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, bool IsReadOnly)=0
Allocate a memory block of (at least) the given size suitable for data.
virtual ~MemoryManager()=default
virtual uint8_t * allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName)=0
Allocate a memory block of (at least) the given size suitable for executable code.
virtual void deregisterEHFrames()=0
virtual bool finalizeMemory(std::string *ErrMsg=nullptr)=0
This method is called when object loading is complete and section page permissions can be applied.
virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size)=0
Register the EH frames with the runtime so that c++ exceptions work.
virtual bool allowStubAllocation() const
Override to return false to tell LLVM no stub space will be needed.
RuntimeDyld(const RuntimeDyld &)=delete
LLVM_ABI void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
Map a section to its target address space value.
void setProcessAllSections(bool ProcessAllSections)
By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager,...
LLVM_ABI void reassignSectionAddress(unsigned SectionID, uint64_t Addr)
LLVM_ABI uint64_t getSectionLoadAddress(unsigned SectionID) const
If the section was loaded, return the section's load address, otherwise return std::nullopt.
LLVM_ABI void * getSymbolLocalAddress(StringRef Name) const
Get the address of our local copy of the symbol.
LLVM_ABI std::map< StringRef, JITEvaluatedSymbol > getSymbolTable() const
Returns a copy of the symbol table.
LLVM_ABI void resolveRelocations()
Resolve the relocations for all symbols we currently know about.
LLVM_ABI void finalizeWithMemoryManagerLocking()
Perform all actions needed to make the code owned by this RuntimeDyld instance executable:
void setNotifyStubEmitted(NotifyStubEmittedFunction NotifyStubEmitted)
Set the NotifyStubEmitted callback.
LLVM_ABI void deregisterEHFrames()
LLVM_ABI void registerEHFrames()
Register any EH frame sections that have been loaded but not previously registered with the memory ma...
LLVM_ABI StringRef getSectionContent(unsigned SectionID) const
Returns the section's working memory.
LLVM_ABI JITEvaluatedSymbol getSymbol(StringRef Name) const
Get the target address and flags for the named symbol.
LLVM_ABI friend void jitLinkForORC(object::OwningBinary< object::ObjectFile > O, RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver, bool ProcessAllSections, unique_function< Error(const object::ObjectFile &Obj, LoadedObjectInfo &, std::map< StringRef, JITEvaluatedSymbol >)> OnLoaded, unique_function< void(object::OwningBinary< object::ObjectFile > O, std::unique_ptr< LoadedObjectInfo >, Error)> OnEmitted)
RuntimeDyld & operator=(const RuntimeDyld &)=delete
LLVM_ABI std::unique_ptr< LoadedObjectInfo > loadObject(const object::ObjectFile &O)
Add the referenced object file to the list of objects to be loaded and relocated.
LLVM_ABI StringRef getErrorString()
LLVM_ABI unsigned getSymbolSectionID(StringRef Name) const
Get the section ID for the section containing the given symbol.
std::function< void(StringRef FileName, StringRef SectionName, StringRef SymbolName, unsigned SectionID, uint32_t StubOffset)> NotifyStubEmittedFunction
StringRef - Represent a constant reference to a string, i.e.
This class is the base class for all object file types.
This is a value type class that represents a single section in the list of sections in the object fil...
This class implements an extremely fast bulk output stream that can only output to a stream.
unique_function is a type-erasing functor similar to std::function.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void jitLinkForORC(object::OwningBinary< object::ObjectFile > O, RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver, bool ProcessAllSections, unique_function< Error(const object::ObjectFile &Obj, RuntimeDyld::LoadedObjectInfo &, std::map< StringRef, JITEvaluatedSymbol >)> OnLoaded, unique_function< void(object::OwningBinary< object::ObjectFile >, std::unique_ptr< RuntimeDyld::LoadedObjectInfo >, Error)> OnEmitted)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
An allocated TLS section.
intptr_t Offset
The TLS offset.
uint8_t * InitializationImage
The pointer to the initialization image.