LLVM: include/llvm/ExecutionEngine/RuntimeDyld.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
14#define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
15
24#include
25#include
26#include
27#include
28#include
29#include
30#include
31#include <system_error>
32
33namespace llvm {
34
36
38
39}
40
41
42
44public:
46
48
51 std::error_code convertToErrorCode() const override;
52
53private:
54 std::string ErrMsg;
55};
56
57class RuntimeDyldImpl;
58
60public:
61
62
64
67 unsigned SectionID, uint32_t StubOffset)>;
68
69
72
73 public:
75
78
81
84
85 protected:
86 virtual void anchor();
87
90 };
91
92
95
96 public:
99
100
101
102
103
105 unsigned SectionID,
107
108
109
110
112 unsigned SectionID,
114 bool IsReadOnly) = 0;
115
116
123
124
125
127 unsigned SectionID,
129
130
131
132
133
134
135
136
137
139 uintptr_t RODataSize, Align RODataAlign,
140 uintptr_t RWDataSize,
141 Align RWDataAlign) {}
142
143
145
146
147
148
150
151
152
153
154
155
156
158 size_t Size) = 0;
160
161
162
163
164
165
166
167
168
169
171
172
173
174
175
176
177
178
179
180
181
182
185
186 private:
187 virtual void anchor();
188
189 bool FinalizationLocked = false;
190 };
191
192
197
198
199
200 LLVM_ABI std::unique_ptr
202
203
204
205
207
208
210
211
212
214
215
216
217
218
219
221
222
224
225
226
227
228
231
232
234
235
236
238
239
240
242 this->NotifyStubEmitted = std::move(NotifyStubEmitted);
243 }
244
245
246
247
248
249
251
253
256
257
258
259
260
261
262
263
264
266 assert(!Dyld && "setProcessAllSections must be called before loadObject.");
267 this->ProcessAllSections = ProcessAllSections;
268 }
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
288
289private:
293 bool ProcessAllSections,
295 std::map<StringRef, JITEvaluatedSymbol>)>
296 OnLoaded,
298 std::unique_ptr, Error)>
299 OnEmitted);
300
301
302
303 std::unique_ptr Dyld;
306 bool ProcessAllSections;
308};
309
310
311
312
313
314
315
319 bool ProcessAllSections,
322 std::map<StringRef, JITEvaluatedSymbol>)>
323 OnLoaded,
325 std::unique_ptrRuntimeDyld::LoadedObjectInfo, Error)>
326 OnEmitted);
327
328}
329
330#endif
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.
const std::string & getErrorMessage() const
Definition RuntimeDyld.h:50
static char ID
Definition RuntimeDyld.h:45
RuntimeDyldError(std::string ErrMsg)
Definition RuntimeDyld.h:47
Information about the loaded object.
Definition RuntimeDyld.h:70
uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const override
Obtain the Load Address of a section by SectionRef.
friend class RuntimeDyldImpl
Definition RuntimeDyld.h:71
std::map< object::SectionRef, unsigned > ObjSectionToIDMap
Definition RuntimeDyld.h:74
ObjSectionToIDMap ObjSecToIDMap
Definition RuntimeDyld.h:89
RuntimeDyldImpl & RTDyld
Definition RuntimeDyld.h:88
virtual object::OwningBinary< object::ObjectFile > getObjectForDebug(const object::ObjectFile &Obj) const =0
LoadedObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap)
Definition RuntimeDyld.h:76
Memory Management.
Definition RuntimeDyld.h:93
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...
Definition RuntimeDyld.h:138
virtual bool needsToReserveAllocationSpace()
Override to return true to enable the reserveAllocationSpace callback.
Definition RuntimeDyld.h:144
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 ...
Definition RuntimeDyld.h:183
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.
Definition RuntimeDyld.h:149
friend class RuntimeDyld
Definition RuntimeDyld.h:94
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,...
Definition RuntimeDyld.h:265
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.
Definition RuntimeDyld.h:241
std::function< void( StringRef FileName, StringRef SectionName, StringRef SymbolName, unsigned SectionID, uint32_t StubOffset)> NotifyStubEmittedFunction
Definition RuntimeDyld.h:65
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)
LLVM_ABI RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver)
Construct a RuntimeDyld instance.
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.
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.
Definition RuntimeDyld.h:117
intptr_t Offset
The TLS offset.
Definition RuntimeDyld.h:121
uint8_t * InitializationImage
The pointer to the initialization image.
Definition RuntimeDyld.h:119