14 #ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
15 #define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
30 #include <system_error>
54 class RuntimeDyldImpl;
55 class RuntimeDyldCheckerImpl;
74 : RTDyld(RTDyld), ObjSecToIDMap(std::move(ObjSecToIDMap)) {}
99 std::unique_ptr<llvm::LoadedObjectInfo>
clone()
const override {
100 return llvm::make_unique<Derived>(
static_cast<const Derived &
>(*this));
126 bool IsReadOnly) = 0;
137 uintptr_t RODataSize,
139 uintptr_t RWDataSize,
182 virtual void anchor();
184 bool FinalizationLocked =
false;
236 assert(!Dyld &&
"setProcessAllSections must be called before loadObject.");
237 this->ProcessAllSections = ProcessAllSections;
262 std::unique_ptr<RuntimeDyldImpl> Dyld;
263 MemoryManager &MemMgr;
265 bool ProcessAllSections;
271 #endif // LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
virtual void reserveAllocationSpace(uintptr_t CodeSize, uint32_t CodeAlign, uintptr_t RODataSize, uint32_t RODataAlign, uintptr_t RWDataSize, uint32_t RWDataAlign)
Inform the memory manager about the total amount of memory required to allocate all sections to be lo...
Information about the loaded object.
std::unique_ptr< LoadedObjectInfo > loadObject(const object::ObjectFile &O)
Add the referenced object file to the list of objects to be loaded and relocated. ...
void registerEHFrames()
Register any EH frame sections that have been loaded but not previously registered with the memory ma...
void operator=(const RuntimeDyld &)=delete
StringRef getErrorString()
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
This class is the base class for all object file types.
uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const override
Obtain the Load Address of a section by SectionRef.
void deregisterEHFrames()
virtual bool needsToReserveAllocationSpace()
Override to return true to enable the reserveAllocationSpace callback.
virtual void deregisterEHFrames(uint8_t *addr, uint64_t LoadAddr, size_t Size)=0
LoadedObjectInfoHelper()=default
JITEvaluatedSymbol getSymbol(StringRef Name) const
Get the target address and flags for the named symbol.
const std::string & getErrorMessage() const
RuntimeDyldError(std::string ErrMsg)
void * getSymbolLocalAddress(StringRef Name) const
Get the address of our local copy of the symbol.
void setProcessAllSections(bool ProcessAllSections)
By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager, and other sections are discarded.
RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver)
Construct a RuntimeDyld instance.
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 notifyObjectLoaded(RuntimeDyld &RTDyld, const object::ObjectFile &Obj)
This method is called after an object has been loaded into memory but before relocations are applied ...
void log(raw_ostream &OS) const override
Print an error message to an output stream.
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 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 object::OwningBinary< object::ObjectFile > getObjectForDebug(const object::ObjectFile &Obj) const =0
ObjSectionToIDMap ObjSecToIDMap
An inferface for inquiring the load address of a loaded object file to be used by the DIContext imple...
Represents a symbol that has been evaluated to an address already.
Base class for user error types.
std::map< object::SectionRef, unsigned > ObjSectionToIDMap
Base class for errors originating in RuntimeDyld, e.g.
std::unique_ptr< llvm::LoadedObjectInfo > clone() const override
Obtain a copy of this LoadedObjectInfo.
void finalizeWithMemoryManagerLocking()
Perform all actions needed to make the code owned by this RuntimeDyld instance executable: ...
void resolveRelocations()
Resolve the relocations for all symbols we currently know about.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LoadedObjectInfoHelper(RuntimeDyldImpl &RTDyld, LoadedObjectInfo::ObjSectionToIDMap ObjSecToIDMap)
This class implements an extremely fast bulk output stream that can only output to a stream...
void reassignSectionAddress(unsigned SectionID, uint64_t Addr)
StringRef - Represent a constant reference to a string, i.e.
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 mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
Map a section to its target address space value.
LoadedObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap)
This is a value type class that represents a single section in the list of sections in the object fil...
virtual ~MemoryManager()=default