13#ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
14#define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
30#include <system_error>
36template <
typename T>
class OwningBinary;
66 unsigned SectionID,
uint32_t StubOffset)>;
113 bool IsReadOnly) = 0;
138 uintptr_t RODataSize,
Align RODataAlign,
139 uintptr_t RWDataSize,
140 Align RWDataAlign) {}
186 virtual void anchor();
188 bool FinalizationLocked =
false;
239 this->NotifyStubEmitted = std::move(NotifyStubEmitted);
263 assert(!Dyld &&
"setProcessAllSections must be called before loadObject.");
264 this->ProcessAllSections = ProcessAllSections;
290 bool ProcessAllSections,
292 std::map<StringRef, JITEvaluatedSymbol>)>
295 std::unique_ptr<LoadedObjectInfo>,
Error)>
300 std::unique_ptr<RuntimeDyldImpl> Dyld;
303 bool ProcessAllSections;
316 bool ProcessAllSections,
319 std::map<StringRef, JITEvaluatedSymbol>)>
322 std::unique_ptr<RuntimeDyld::LoadedObjectInfo>,
Error)>
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
void log(raw_ostream &OS) const override
Print an error message to an output stream.
const std::string & getErrorMessage() const
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
RuntimeDyldError(std::string ErrMsg)
Information about the loaded object.
uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const override
Obtain the Load Address of a section by SectionRef.
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 TLSSection allocateTLSSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName)
Allocate a memory block of (at least) the given size to be used for thread-local storage (TLS).
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
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,...
void reassignSectionAddress(unsigned SectionID, uint64_t Addr)
uint64_t getSectionLoadAddress(unsigned SectionID) const
If the section was loaded, return the section's load address, otherwise return std::nullopt.
void * getSymbolLocalAddress(StringRef Name) const
Get the address of our local copy of the symbol.
std::map< StringRef, JITEvaluatedSymbol > getSymbolTable() const
Returns a copy of the symbol table.
void resolveRelocations()
Resolve the relocations for all symbols we currently know about.
void finalizeWithMemoryManagerLocking()
Perform all actions needed to make the code owned by this RuntimeDyld instance executable:
void setNotifyStubEmitted(NotifyStubEmittedFunction NotifyStubEmitted)
Set the NotifyStubEmitted callback.
void deregisterEHFrames()
void registerEHFrames()
Register any EH frame sections that have been loaded but not previously registered with the memory ma...
StringRef getSectionContent(unsigned SectionID) const
Returns the section's working memory.
JITEvaluatedSymbol getSymbol(StringRef Name) const
Get the target address and flags for the named symbol.
RuntimeDyld & operator=(const RuntimeDyld &)=delete
std::unique_ptr< LoadedObjectInfo > loadObject(const object::ObjectFile &O)
Add the referenced object file to the list of objects to be loaded and relocated.
StringRef getErrorString()
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
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)
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.
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.