Go to the documentation of this file.
13 #ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
14 #define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
30 #include <system_error>
56 class RuntimeDyldImpl;
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;
301 MemoryManager &MemMgr;
303 bool ProcessAllSections;
314 object::OwningBinary<object::ObjectFile>
O,
315 RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver,
316 bool ProcessAllSections,
317 unique_function<Error(
const object::ObjectFile &Obj,
318 RuntimeDyld::LoadedObjectInfo &,
319 std::map<StringRef, JITEvaluatedSymbol>)>
321 unique_function<
void(object::OwningBinary<object::ObjectFile>,
322 std::unique_ptr<RuntimeDyld::LoadedObjectInfo>, Error)>
327 #endif // LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
RuntimeDyldError(std::string ErrMsg)
virtual ~MemoryManager()=default
uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const override
Obtain the Load Address of a section by SectionRef.
void log(raw_ostream &OS) const override
Print an error message to an output stream.
This is an optimization pass for GlobalISel generic memory operations.
unique_function is a type-erasing functor similar to std::function.
virtual object::OwningBinary< object::ObjectFile > getObjectForDebug(const object::ObjectFile &Obj) const =0
virtual void deregisterEHFrames()=0
ObjSectionToIDMap ObjSecToIDMap
Base class for errors originating in RuntimeDyld, e.g.
void resolveRelocations()
Resolve the relocations for all symbols we currently know about.
intptr_t Offset
The TLS offset.
Represents a symbol that has been evaluated to an address already.
void setProcessAllSections(bool ProcessAllSections)
By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager,...
std::unique_ptr< LoadedObjectInfo > loadObject(const object::ObjectFile &O)
Add the referenced object file to the list of objects to be loaded and relocated.
LoadedObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap)
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
RuntimeDyld & operator=(const RuntimeDyld &)=delete
void reassignSectionAddress(unsigned SectionID, uint64_t Addr)
void setNotifyStubEmitted(NotifyStubEmittedFunction NotifyStubEmitted)
Set the NotifyStubEmitted callback.
unsigned getSymbolSectionID(StringRef Name) const
Get the section ID for the section containing the given symbol.
This class implements an extremely fast bulk output stream that can only output to a stream.
virtual bool needsToReserveAllocationSpace()
Override to return true to enable the reserveAllocationSpace callback.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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.
void registerEHFrames()
Register any EH frame sections that have been loaded but not previously registered with the memory ma...
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)
This is a value type class that represents a single section in the list of sections in the object fil...
virtual bool finalizeMemory(std::string *ErrMsg=nullptr)=0
This method is called when object loading is complete and section page permissions can be applied.
bar al al movzbl eax ret Missed when stored in a memory object
uint8_t * InitializationImage
The pointer to the initialization image.
const std::string & getErrorMessage() const
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
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)
StringRef getSectionContent(unsigned SectionID) const
Returns the section's working memory.
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 ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver)
Construct a RuntimeDyld instance.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
std::function< void(StringRef FileName, StringRef SectionName, StringRef SymbolName, unsigned SectionID, uint32_t StubOffset)> NotifyStubEmittedFunction
uint64_t getSectionLoadAddress(unsigned SectionID) const
If the section was loaded, return the section's load address, otherwise return std::nullopt.
print Print MemDeps of function
Base class for user error types.
void finalizeWithMemoryManagerLocking()
Perform all actions needed to make the code owned by this RuntimeDyld instance executable:
StringRef - Represent a constant reference to a string, i.e.
This class is the base class for all object file types.
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.
std::map< object::SectionRef, unsigned > ObjSectionToIDMap
Symbol resolution interface.
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Information about the loaded object.
Lightweight error class with error context and mandatory checking.
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...
StringRef getErrorString()
An inferface for inquiring the load address of a loaded object file to be used by the DIContext imple...
void * getSymbolLocalAddress(StringRef Name) const
Get the address of our local copy of the symbol.
virtual bool allowStubAllocation() const
Override to return false to tell LLVM no stub space will be needed.
void deregisterEHFrames()
JITEvaluatedSymbol getSymbol(StringRef Name) const
Get the target address and flags for the named symbol.
An allocated TLS section.
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.
void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
Map a section to its target address space value.
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).
std::map< StringRef, JITEvaluatedSymbol > getSymbolTable() const
Returns a copy of the symbol table.