LLVM  14.0.0git
RuntimeDyldImpl.h
Go to the documentation of this file.
1 //===-- RuntimeDyldImpl.h - Run-time dynamic linker for MC-JIT --*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Interface for the implementations of runtime dynamic linker facilities.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDIMPL_H
14 #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_RUNTIMEDYLDIMPL_H
15 
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/ADT/StringMap.h"
18 #include "llvm/ADT/Triple.h"
22 #include "llvm/Object/ObjectFile.h"
23 #include "llvm/Support/Debug.h"
25 #include "llvm/Support/Format.h"
26 #include "llvm/Support/Host.h"
27 #include "llvm/Support/Mutex.h"
29 #include <deque>
30 #include <map>
31 #include <system_error>
32 #include <unordered_map>
33 
34 using namespace llvm;
35 using namespace llvm::object;
36 
37 namespace llvm {
38 
39 #define UNIMPLEMENTED_RELOC(RelType) \
40  case RelType: \
41  return make_error<RuntimeDyldError>("Unimplemented relocation: " #RelType)
42 
43 /// SectionEntry - represents a section emitted into memory by the dynamic
44 /// linker.
45 class SectionEntry {
46  /// Name - section name.
47  std::string Name;
48 
49  /// Address - address in the linker's memory where the section resides.
50  uint8_t *Address;
51 
52  /// Size - section size. Doesn't include the stubs.
53  size_t Size;
54 
55  /// LoadAddress - the address of the section in the target process's memory.
56  /// Used for situations in which JIT-ed code is being executed in the address
57  /// space of a separate process. If the code executes in the same address
58  /// space where it was JIT-ed, this just equals Address.
59  uint64_t LoadAddress;
60 
61  /// StubOffset - used for architectures with stub functions for far
62  /// relocations (like ARM).
63  uintptr_t StubOffset;
64 
65  /// The total amount of space allocated for this section. This includes the
66  /// section size and the maximum amount of space that the stubs can occupy.
67  size_t AllocationSize;
68 
69  /// ObjAddress - address of the section in the in-memory object file. Used
70  /// for calculating relocations in some object formats (like MachO).
71  uintptr_t ObjAddress;
72 
73 public:
74  SectionEntry(StringRef name, uint8_t *address, size_t size,
75  size_t allocationSize, uintptr_t objAddress)
76  : Name(std::string(name)), Address(address), Size(size),
77  LoadAddress(reinterpret_cast<uintptr_t>(address)), StubOffset(size),
78  AllocationSize(allocationSize), ObjAddress(objAddress) {
79  // AllocationSize is used only in asserts, prevent an "unused private field"
80  // warning:
81  (void)AllocationSize;
82  }
83 
84  StringRef getName() const { return Name; }
85 
86  uint8_t *getAddress() const { return Address; }
87 
88  /// Return the address of this section with an offset.
89  uint8_t *getAddressWithOffset(unsigned OffsetBytes) const {
90  assert(OffsetBytes <= AllocationSize && "Offset out of bounds!");
91  return Address + OffsetBytes;
92  }
93 
94  size_t getSize() const { return Size; }
95 
96  uint64_t getLoadAddress() const { return LoadAddress; }
97  void setLoadAddress(uint64_t LA) { LoadAddress = LA; }
98 
99  /// Return the load address of this section with an offset.
100  uint64_t getLoadAddressWithOffset(unsigned OffsetBytes) const {
101  assert(OffsetBytes <= AllocationSize && "Offset out of bounds!");
102  return LoadAddress + OffsetBytes;
103  }
104 
105  uintptr_t getStubOffset() const { return StubOffset; }
106 
107  void advanceStubOffset(unsigned StubSize) {
108  StubOffset += StubSize;
109  assert(StubOffset <= AllocationSize && "Not enough space allocated!");
110  }
111 
112  uintptr_t getObjAddress() const { return ObjAddress; }
113 };
114 
115 /// RelocationEntry - used to represent relocations internally in the dynamic
116 /// linker.
118 public:
119  /// SectionID - the section this relocation points to.
120  unsigned SectionID;
121 
122  /// Offset - offset into the section.
124 
125  /// RelType - relocation type.
127 
128  /// Addend - the relocation addend encoded in the instruction itself. Also
129  /// used to make a relocation section relative instead of symbol relative.
130  int64_t Addend;
131 
132  struct SectionPair {
135  };
136 
137  /// SymOffset - Section offset of the relocation entry's symbol (used for GOT
138  /// lookup).
139  union {
142  };
143 
144  /// True if this is a PCRel relocation (MachO specific).
145  bool IsPCRel;
146 
147  /// The size of this relocation (MachO specific).
148  unsigned Size;
149 
150  // ARM (MachO and COFF) specific.
151  bool IsTargetThumbFunc = false;
152 
153  RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend)
154  : SectionID(id), Offset(offset), RelType(type), Addend(addend),
155  SymOffset(0), IsPCRel(false), Size(0), IsTargetThumbFunc(false) {}
156 
157  RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend,
158  uint64_t symoffset)
159  : SectionID(id), Offset(offset), RelType(type), Addend(addend),
160  SymOffset(symoffset), IsPCRel(false), Size(0),
161  IsTargetThumbFunc(false) {}
162 
163  RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend,
164  bool IsPCRel, unsigned Size)
165  : SectionID(id), Offset(offset), RelType(type), Addend(addend),
166  SymOffset(0), IsPCRel(IsPCRel), Size(Size), IsTargetThumbFunc(false) {}
167 
168  RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend,
169  unsigned SectionA, uint64_t SectionAOffset, unsigned SectionB,
170  uint64_t SectionBOffset, bool IsPCRel, unsigned Size)
171  : SectionID(id), Offset(offset), RelType(type),
172  Addend(SectionAOffset - SectionBOffset + addend), IsPCRel(IsPCRel),
173  Size(Size), IsTargetThumbFunc(false) {
174  Sections.SectionA = SectionA;
175  Sections.SectionB = SectionB;
176  }
177 
178  RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend,
179  unsigned SectionA, uint64_t SectionAOffset, unsigned SectionB,
180  uint64_t SectionBOffset, bool IsPCRel, unsigned Size,
181  bool IsTargetThumbFunc)
182  : SectionID(id), Offset(offset), RelType(type),
183  Addend(SectionAOffset - SectionBOffset + addend), IsPCRel(IsPCRel),
184  Size(Size), IsTargetThumbFunc(IsTargetThumbFunc) {
185  Sections.SectionA = SectionA;
186  Sections.SectionB = SectionB;
187  }
188 };
189 
191 public:
192  unsigned SectionID = 0;
194  int64_t Addend = 0;
195  const char *SymbolName = nullptr;
196  bool IsStubThumb = false;
197 
198  inline bool operator==(const RelocationValueRef &Other) const {
199  return SectionID == Other.SectionID && Offset == Other.Offset &&
200  Addend == Other.Addend && SymbolName == Other.SymbolName &&
201  IsStubThumb == Other.IsStubThumb;
202  }
203  inline bool operator<(const RelocationValueRef &Other) const {
204  if (SectionID != Other.SectionID)
205  return SectionID < Other.SectionID;
206  if (Offset != Other.Offset)
207  return Offset < Other.Offset;
208  if (Addend != Other.Addend)
209  return Addend < Other.Addend;
210  if (IsStubThumb != Other.IsStubThumb)
211  return IsStubThumb < Other.IsStubThumb;
212  return SymbolName < Other.SymbolName;
213  }
214 };
215 
216 /// Symbol info for RuntimeDyld.
218 public:
219  SymbolTableEntry() = default;
220 
221  SymbolTableEntry(unsigned SectionID, uint64_t Offset, JITSymbolFlags Flags)
222  : Offset(Offset), SectionID(SectionID), Flags(Flags) {}
223 
224  unsigned getSectionID() const { return SectionID; }
225  uint64_t getOffset() const { return Offset; }
226  void setOffset(uint64_t NewOffset) { Offset = NewOffset; }
227 
228  JITSymbolFlags getFlags() const { return Flags; }
229 
230 private:
231  uint64_t Offset = 0;
232  unsigned SectionID = 0;
234 };
235 
237 
240 protected:
241  static const unsigned AbsoluteSymbolSection = ~0U;
242 
243  // The MemoryManager to load objects into.
245 
246  // The symbol resolver to use for external symbols.
248 
249  // A list of all sections emitted by the dynamic linker. These sections are
250  // referenced in the code by means of their index in this list - SectionID.
251  // Because references may be kept while the list grows, use a container that
252  // guarantees reference stability.
253  typedef std::deque<SectionEntry> SectionList;
255 
256  typedef unsigned SID; // Type for SectionIDs
257 #define RTDYLD_INVALID_SECTION_ID ((RuntimeDyldImpl::SID)(-1))
258 
259  // Keep a map of sections from object file to the SectionID which
260  // references it.
261  typedef std::map<SectionRef, unsigned> ObjSectionToIDMap;
262 
263  // A global symbol table for symbols from all loaded modules.
265 
266  // Keep a map of common symbols to their info pairs
267  typedef std::vector<SymbolRef> CommonSymbolList;
268 
269  // For each symbol, keep a list of relocations based on it. Anytime
270  // its address is reassigned (the JIT re-compiled the function, e.g.),
271  // the relocations get re-resolved.
272  // The symbol (or section) the relocation is sourced from is the Key
273  // in the relocation list where it's stored.
275  // Relocations to sections already loaded. Indexed by SectionID which is the
276  // source of the address. The target where the address will be written is
277  // SectionID/Offset in the relocation itself.
278  std::unordered_map<unsigned, RelocationList> Relocations;
279 
280  // Relocations to external symbols that are not yet resolved. Symbols are
281  // external when they aren't found in the global symbol table of all loaded
282  // modules. This map is indexed by symbol name.
284 
285 
286  typedef std::map<RelocationValueRef, uintptr_t> StubMap;
287 
293 
294  // True if all sections should be passed to the memory manager, false if only
295  // sections containing relocations should be. Defaults to 'false'.
297 
298  // This mutex prevents simultaneously loading objects from two different
299  // threads. This keeps us from having to protect individual data structures
300  // and guarantees that section allocation requests to the memory manager
301  // won't be interleaved between modules. It is also used in mapSectionAddress
302  // and resolveRelocations to protect write access to internal data structures.
303  //
304  // loadObject may be called on the same thread during the handling of of
305  // processRelocations, and that's OK. The handling of the relocation lists
306  // is written in such a way as to work correctly if new elements are added to
307  // the end of the list while the list is being processed.
309 
313 
314  virtual unsigned getMaxStubSize() const = 0;
315  virtual unsigned getStubAlignment() = 0;
316 
317  bool HasError;
318  std::string ErrorStr;
319 
320  void writeInt16BE(uint8_t *Addr, uint16_t Value) {
321  llvm::support::endian::write<uint16_t, llvm::support::unaligned>(
322  Addr, Value, IsTargetLittleEndian ? support::little : support::big);
323  }
324 
325  void writeInt32BE(uint8_t *Addr, uint32_t Value) {
326  llvm::support::endian::write<uint32_t, llvm::support::unaligned>(
327  Addr, Value, IsTargetLittleEndian ? support::little : support::big);
328  }
329 
330  void writeInt64BE(uint8_t *Addr, uint64_t Value) {
331  llvm::support::endian::write<uint64_t, llvm::support::unaligned>(
332  Addr, Value, IsTargetLittleEndian ? support::little : support::big);
333  }
334 
335  virtual void setMipsABI(const ObjectFile &Obj) {
336  IsMipsO32ABI = false;
337  IsMipsN32ABI = false;
338  IsMipsN64ABI = false;
339  }
340 
341  /// Endian-aware read Read the least significant Size bytes from Src.
342  uint64_t readBytesUnaligned(uint8_t *Src, unsigned Size) const;
343 
344  /// Endian-aware write. Write the least significant Size bytes from Value to
345  /// Dst.
346  void writeBytesUnaligned(uint64_t Value, uint8_t *Dst, unsigned Size) const;
347 
348  /// Generate JITSymbolFlags from a libObject symbol.
349  virtual Expected<JITSymbolFlags> getJITSymbolFlags(const SymbolRef &Sym);
350 
351  /// Modify the given target address based on the given symbol flags.
352  /// This can be used by subclasses to tweak addresses based on symbol flags,
353  /// For example: the MachO/ARM target uses it to set the low bit if the target
354  /// is a thumb symbol.
356  JITSymbolFlags Flags) const {
357  return Addr;
358  }
359 
360  /// Given the common symbols discovered in the object file, emit a
361  /// new section for them and update the symbol mappings in the object and
362  /// symbol table.
363  Error emitCommonSymbols(const ObjectFile &Obj,
364  CommonSymbolList &CommonSymbols, uint64_t CommonSize,
365  uint32_t CommonAlign);
366 
367  /// Emits section data from the object file to the MemoryManager.
368  /// \param IsCode if it's true then allocateCodeSection() will be
369  /// used for emits, else allocateDataSection() will be used.
370  /// \return SectionID.
371  Expected<unsigned> emitSection(const ObjectFile &Obj,
372  const SectionRef &Section,
373  bool IsCode);
374 
375  /// Find Section in LocalSections. If the secton is not found - emit
376  /// it and store in LocalSections.
377  /// \param IsCode if it's true then allocateCodeSection() will be
378  /// used for emmits, else allocateDataSection() will be used.
379  /// \return SectionID.
380  Expected<unsigned> findOrEmitSection(const ObjectFile &Obj,
381  const SectionRef &Section, bool IsCode,
382  ObjSectionToIDMap &LocalSections);
383 
384  // Add a relocation entry that uses the given section.
385  void addRelocationForSection(const RelocationEntry &RE, unsigned SectionID);
386 
387  // Add a relocation entry that uses the given symbol. This symbol may
388  // be found in the global symbol table, or it may be external.
389  void addRelocationForSymbol(const RelocationEntry &RE, StringRef SymbolName);
390 
391  /// Emits long jump instruction to Addr.
392  /// \return Pointer to the memory area for emitting target address.
393  uint8_t *createStubFunction(uint8_t *Addr, unsigned AbiVariant = 0);
394 
395  /// Resolves relocations from Relocs list with address from Value.
396  void resolveRelocationList(const RelocationList &Relocs, uint64_t Value);
397 
398  /// A object file specific relocation resolver
399  /// \param RE The relocation to be resolved
400  /// \param Value Target symbol address to apply the relocation action
401  virtual void resolveRelocation(const RelocationEntry &RE, uint64_t Value) = 0;
402 
403  /// Parses one or more object file relocations (some object files use
404  /// relocation pairs) and stores it to Relocations or SymbolRelocations
405  /// (this depends on the object file type).
406  /// \return Iterator to the next relocation that needs to be parsed.
408  processRelocationRef(unsigned SectionID, relocation_iterator RelI,
409  const ObjectFile &Obj, ObjSectionToIDMap &ObjSectionToID,
410  StubMap &Stubs) = 0;
411 
412  void applyExternalSymbolRelocations(
413  const StringMap<JITEvaluatedSymbol> ExternalSymbolMap);
414 
415  /// Resolve relocations to external symbols.
416  Error resolveExternalSymbols();
417 
418  // Compute an upper bound of the memory that is required to load all
419  // sections
420  Error computeTotalAllocSize(const ObjectFile &Obj,
421  uint64_t &CodeSize, uint32_t &CodeAlign,
422  uint64_t &RODataSize, uint32_t &RODataAlign,
423  uint64_t &RWDataSize, uint32_t &RWDataAlign);
424 
425  // Compute GOT size
426  unsigned computeGOTSize(const ObjectFile &Obj);
427 
428  // Compute the stub buffer size required for a section
429  unsigned computeSectionStubBufSize(const ObjectFile &Obj,
430  const SectionRef &Section);
431 
432  // Implementation of the generic part of the loadObject algorithm.
433  Expected<ObjSectionToIDMap> loadObjectImpl(const object::ObjectFile &Obj);
434 
435  // Return size of Global Offset Table (GOT) entry
436  virtual size_t getGOTEntrySize() { return 0; }
437 
438  // Return true if the relocation R may require allocating a GOT entry.
439  virtual bool relocationNeedsGot(const RelocationRef &R) const {
440  return false;
441  }
442 
443  // Return true if the relocation R may require allocating a stub.
444  virtual bool relocationNeedsStub(const RelocationRef &R) const {
445  return true; // Conservative answer
446  }
447 
448 public:
451  : MemMgr(MemMgr), Resolver(Resolver),
452  ProcessAllSections(false), HasError(false) {
453  }
454 
455  virtual ~RuntimeDyldImpl();
456 
457  void setProcessAllSections(bool ProcessAllSections) {
458  this->ProcessAllSections = ProcessAllSections;
459  }
460 
461  virtual std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
462  loadObject(const object::ObjectFile &Obj) = 0;
463 
464  uint64_t getSectionLoadAddress(unsigned SectionID) const {
465  if (SectionID == AbsoluteSymbolSection)
466  return 0;
467  else
468  return Sections[SectionID].getLoadAddress();
469  }
470 
471  uint8_t *getSectionAddress(unsigned SectionID) const {
472  if (SectionID == AbsoluteSymbolSection)
473  return nullptr;
474  else
475  return Sections[SectionID].getAddress();
476  }
477 
478  StringRef getSectionContent(unsigned SectionID) const {
479  if (SectionID == AbsoluteSymbolSection)
480  return {};
481  else
482  return StringRef(
483  reinterpret_cast<char *>(Sections[SectionID].getAddress()),
484  Sections[SectionID].getStubOffset() + getMaxStubSize());
485  }
486 
488  // FIXME: Just look up as a function for now. Overly simple of course.
489  // Work in progress.
490  RTDyldSymbolTable::const_iterator pos = GlobalSymbolTable.find(Name);
491  if (pos == GlobalSymbolTable.end())
492  return nullptr;
493  const auto &SymInfo = pos->second;
494  // Absolute symbols do not have a local address.
495  if (SymInfo.getSectionID() == AbsoluteSymbolSection)
496  return nullptr;
497  return getSectionAddress(SymInfo.getSectionID()) + SymInfo.getOffset();
498  }
499 
501  auto GSTItr = GlobalSymbolTable.find(Name);
502  if (GSTItr == GlobalSymbolTable.end())
503  return ~0U;
504  return GSTItr->second.getSectionID();
505  }
506 
508  // FIXME: Just look up as a function for now. Overly simple of course.
509  // Work in progress.
510  RTDyldSymbolTable::const_iterator pos = GlobalSymbolTable.find(Name);
511  if (pos == GlobalSymbolTable.end())
512  return nullptr;
513  const auto &SymEntry = pos->second;
514  uint64_t SectionAddr = 0;
515  if (SymEntry.getSectionID() != AbsoluteSymbolSection)
516  SectionAddr = getSectionLoadAddress(SymEntry.getSectionID());
517  uint64_t TargetAddr = SectionAddr + SymEntry.getOffset();
518 
519  // FIXME: Have getSymbol should return the actual address and the client
520  // modify it based on the flags. This will require clients to be
521  // aware of the target architecture, which we should build
522  // infrastructure for.
523  TargetAddr = modifyAddressBasedOnFlags(TargetAddr, SymEntry.getFlags());
524  return JITEvaluatedSymbol(TargetAddr, SymEntry.getFlags());
525  }
526 
527  std::map<StringRef, JITEvaluatedSymbol> getSymbolTable() const {
528  std::map<StringRef, JITEvaluatedSymbol> Result;
529 
530  for (auto &KV : GlobalSymbolTable) {
531  auto SectionID = KV.second.getSectionID();
532  uint64_t SectionAddr = getSectionLoadAddress(SectionID);
533  Result[KV.first()] =
534  JITEvaluatedSymbol(SectionAddr + KV.second.getOffset(), KV.second.getFlags());
535  }
536 
537  return Result;
538  }
539 
540  void resolveRelocations();
541 
542  void resolveLocalRelocations();
543 
544  static void finalizeAsync(
545  std::unique_ptr<RuntimeDyldImpl> This,
547  std::unique_ptr<RuntimeDyld::LoadedObjectInfo>,
548  Error)>
549  OnEmitted,
551  std::unique_ptr<RuntimeDyld::LoadedObjectInfo> Info);
552 
553  void reassignSectionAddress(unsigned SectionID, uint64_t Addr);
554 
555  void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress);
556 
557  // Is the linker in an error state?
558  bool hasError() { return HasError; }
559 
560  // Mark the error condition as handled and continue.
561  void clearError() { HasError = false; }
562 
563  // Get the error message.
564  StringRef getErrorString() { return ErrorStr; }
565 
566  virtual bool isCompatibleFile(const ObjectFile &Obj) const = 0;
567 
569  this->NotifyStubEmitted = std::move(NotifyStubEmitted);
570  }
571 
572  virtual void registerEHFrames();
573 
574  void deregisterEHFrames();
575 
576  virtual Error finalizeLoad(const ObjectFile &ObjImg,
577  ObjSectionToIDMap &SectionMap) {
578  return Error::success();
579  }
580 };
581 
582 } // end namespace llvm
583 
584 #endif
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::RuntimeDyldImpl::clearError
void clearError()
Definition: RuntimeDyldImpl.h:561
llvm::RuntimeDyldImpl::writeInt64BE
void writeInt64BE(uint8_t *Addr, uint64_t Value)
Definition: RuntimeDyldImpl.h:330
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::SectionEntry::getAddress
uint8_t * getAddress() const
Definition: RuntimeDyldImpl.h:86
llvm::RelocationValueRef::operator==
bool operator==(const RelocationValueRef &Other) const
Definition: RuntimeDyldImpl.h:198
llvm::RuntimeDyldImpl::Resolver
JITSymbolResolver & Resolver
Definition: RuntimeDyldImpl.h:247
llvm::RuntimeDyldImpl::MemMgr
RuntimeDyld::MemoryManager & MemMgr
Definition: RuntimeDyldImpl.h:244
llvm::object::SymEntry
Definition: SymbolSize.h:18
RuntimeDyldChecker.h
type
llvm::RuntimeDyldImpl::CommonSymbolList
std::vector< SymbolRef > CommonSymbolList
Definition: RuntimeDyldImpl.h:267
llvm::unique_function
unique_function is a type-erasing functor similar to std::function.
Definition: FunctionExtras.h:56
llvm::RuntimeDyldImpl::getSymbolSectionID
unsigned getSymbolSectionID(StringRef Name) const
Definition: RuntimeDyldImpl.h:500
llvm::SymbolTableEntry::getSectionID
unsigned getSectionID() const
Definition: RuntimeDyldImpl.h:224
llvm::RuntimeDyldImpl::getGOTEntrySize
virtual size_t getGOTEntrySize()
Definition: RuntimeDyldImpl.h:436
llvm::RuntimeDyldImpl::getSymbol
JITEvaluatedSymbol getSymbol(StringRef Name) const
Definition: RuntimeDyldImpl.h:507
llvm::RelocationEntry::SectionPair::SectionA
uint32_t SectionA
Definition: RuntimeDyldImpl.h:133
llvm::SectionEntry::getStubOffset
uintptr_t getStubOffset() const
Definition: RuntimeDyldImpl.h:105
llvm::RuntimeDyldImpl::ErrorStr
std::string ErrorStr
Definition: RuntimeDyldImpl.h:318
llvm::RuntimeDyldImpl::Sections
SectionList Sections
Definition: RuntimeDyldImpl.h:254
llvm::RelocationEntry::IsPCRel
bool IsPCRel
True if this is a PCRel relocation (MachO specific).
Definition: RuntimeDyldImpl.h:145
Host.h
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
ErrorHandling.h
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::RuntimeDyldImpl::getSymbolLocalAddress
uint8_t * getSymbolLocalAddress(StringRef Name) const
Definition: RuntimeDyldImpl.h:487
SwapByteOrder.h
llvm::SectionEntry::getAddressWithOffset
uint8_t * getAddressWithOffset(unsigned OffsetBytes) const
Return the address of this section with an offset.
Definition: RuntimeDyldImpl.h:89
llvm::StringMap::end
iterator end()
Definition: StringMap.h:203
llvm::RelocationEntry::RelocationEntry
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend, uint64_t symoffset)
Definition: RuntimeDyldImpl.h:157
llvm::SectionEntry::setLoadAddress
void setLoadAddress(uint64_t LA)
Definition: RuntimeDyldImpl.h:97
llvm::SymbolTableEntry::getOffset
uint64_t getOffset() const
Definition: RuntimeDyldImpl.h:225
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::RuntimeDyldImpl
Definition: RuntimeDyldImpl.h:238
llvm::RTDyldSymbolTable
StringMap< SymbolTableEntry > RTDyldSymbolTable
Definition: RuntimeDyldImpl.h:236
llvm::StringMap::find
iterator find(StringRef Key)
Definition: StringMap.h:216
Format.h
llvm::RuntimeDyldImpl::IsMipsO32ABI
bool IsMipsO32ABI
Definition: RuntimeDyldImpl.h:290
RuntimeDyld.h
llvm::RuntimeDyldImpl::lock
sys::Mutex lock
Definition: RuntimeDyldImpl.h:308
llvm::JITSymbolFlags
Flags for symbols in the JIT.
Definition: JITSymbol.h:74
llvm::RelocationEntry::SymOffset
uint64_t SymOffset
Definition: RuntimeDyldImpl.h:140
llvm::RuntimeDyldImpl::setMipsABI
virtual void setMipsABI(const ObjectFile &Obj)
Definition: RuntimeDyldImpl.h:335
llvm::RuntimeDyldImpl::NotifyStubEmittedFunction
RuntimeDyld::NotifyStubEmittedFunction NotifyStubEmittedFunction
Definition: RuntimeDyldImpl.h:311
llvm::RuntimeDyldImpl::setNotifyStubEmitted
void setNotifyStubEmitted(NotifyStubEmittedFunction NotifyStubEmitted)
Definition: RuntimeDyldImpl.h:568
llvm::JITEvaluatedSymbol
Represents a symbol that has been evaluated to an address already.
Definition: JITSymbol.h:229
llvm::RISCVFenceField::R
@ R
Definition: RISCVBaseInfo.h:198
llvm::RelocationEntry::SectionID
unsigned SectionID
SectionID - the section this relocation points to.
Definition: RuntimeDyldImpl.h:120
llvm::RuntimeDyldImpl::finalizeLoad
virtual Error finalizeLoad(const ObjectFile &ObjImg, ObjSectionToIDMap &SectionMap)
Definition: RuntimeDyldImpl.h:576
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::Resolver
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:2000
llvm::RelocationEntry::Offset
uint64_t Offset
Offset - offset into the section.
Definition: RuntimeDyldImpl.h:123
llvm::object
Definition: ObjectFileTransformer.h:18
llvm::RuntimeDyldImpl::HasError
bool HasError
Definition: RuntimeDyldImpl.h:317
llvm::Triple::ArchType
ArchType
Definition: Triple.h:47
llvm::RuntimeDyldImpl::SID
unsigned SID
Definition: RuntimeDyldImpl.h:256
llvm::RelocationEntry::RelocationEntry
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend)
Definition: RuntimeDyldImpl.h:153
llvm::RuntimeDyldImpl::IsMipsN64ABI
bool IsMipsN64ABI
Definition: RuntimeDyldImpl.h:292
llvm::RuntimeDyldImpl::SectionList
std::deque< SectionEntry > SectionList
Definition: RuntimeDyldImpl.h:253
llvm::support::little
@ little
Definition: Endian.h:27
llvm::StringMapConstIterator
Definition: StringMap.h:24
llvm::SymbolTableEntry::SymbolTableEntry
SymbolTableEntry(unsigned SectionID, uint64_t Offset, JITSymbolFlags Flags)
Definition: RuntimeDyldImpl.h:221
llvm::RelocationEntry::RelocationEntry
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend, unsigned SectionA, uint64_t SectionAOffset, unsigned SectionB, uint64_t SectionBOffset, bool IsPCRel, unsigned Size)
Definition: RuntimeDyldImpl.h:168
false
Definition: StackSlotColoring.cpp:142
llvm::RuntimeDyldImpl::getSectionAddress
uint8_t * getSectionAddress(unsigned SectionID) const
Definition: RuntimeDyldImpl.h:471
llvm::SectionEntry::SectionEntry
SectionEntry(StringRef name, uint8_t *address, size_t size, size_t allocationSize, uintptr_t objAddress)
Definition: RuntimeDyldImpl.h:74
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
StringMap.h
llvm::RuntimeDyldImpl::modifyAddressBasedOnFlags
virtual uint64_t modifyAddressBasedOnFlags(uint64_t Addr, JITSymbolFlags Flags) const
Modify the given target address based on the given symbol flags.
Definition: RuntimeDyldImpl.h:355
llvm::sys::SmartMutex< false >
llvm::SectionEntry::getObjAddress
uintptr_t getObjAddress() const
Definition: RuntimeDyldImpl.h:112
llvm::RuntimeDyldImpl::writeInt32BE
void writeInt32BE(uint8_t *Addr, uint32_t Value)
Definition: RuntimeDyldImpl.h:325
llvm::StringMap< SymbolTableEntry >
llvm::RuntimeDyldImpl::getSectionLoadAddress
uint64_t getSectionLoadAddress(unsigned SectionID) const
Definition: RuntimeDyldImpl.h:464
llvm::RelocationEntry::Addend
int64_t Addend
Addend - the relocation addend encoded in the instruction itself.
Definition: RuntimeDyldImpl.h:130
llvm::object::SectionRef
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:80
llvm::RelocationEntry
RelocationEntry - used to represent relocations internally in the dynamic linker.
Definition: RuntimeDyldImpl.h:117
llvm::RuntimeDyldImpl::ExternalSymbolRelocations
StringMap< RelocationList > ExternalSymbolRelocations
Definition: RuntimeDyldImpl.h:283
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:197
llvm::RuntimeDyldImpl::ProcessAllSections
bool ProcessAllSections
Definition: RuntimeDyldImpl.h:296
uint64_t
llvm::RelocationEntry::Size
unsigned Size
The size of this relocation (MachO specific).
Definition: RuntimeDyldImpl.h:148
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:80
llvm::RelocationEntry::SectionPair
Definition: RuntimeDyldImpl.h:132
llvm::RuntimeDyldImpl::getSectionContent
StringRef getSectionContent(unsigned SectionID) const
Definition: RuntimeDyldImpl.h:478
llvm::RuntimeDyldImpl::relocationNeedsStub
virtual bool relocationNeedsStub(const RelocationRef &R) const
Definition: RuntimeDyldImpl.h:444
move
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
Definition: README.txt:546
llvm::RuntimeDyldImpl::IsTargetLittleEndian
bool IsTargetLittleEndian
Definition: RuntimeDyldImpl.h:289
llvm::RuntimeDyldImpl::getErrorString
StringRef getErrorString()
Definition: RuntimeDyldImpl.h:564
llvm::SectionEntry
SectionEntry - represents a section emitted into memory by the dynamic linker.
Definition: RuntimeDyldImpl.h:45
llvm::RelocationEntry::RelocationEntry
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend, bool IsPCRel, unsigned Size)
Definition: RuntimeDyldImpl.h:163
llvm::HighlightColor::Address
@ Address
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ObjectFile.h
llvm::object::content_iterator
Definition: SymbolicFile.h:67
llvm::RelocationEntry::RelocationEntry
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend, unsigned SectionA, uint64_t SectionAOffset, unsigned SectionB, uint64_t SectionBOffset, bool IsPCRel, unsigned Size, bool IsTargetThumbFunc)
Definition: RuntimeDyldImpl.h:178
llvm::RuntimeDyld::NotifyStubEmittedFunction
std::function< void(StringRef FileName, StringRef SectionName, StringRef SymbolName, unsigned SectionID, uint32_t StubOffset)> NotifyStubEmittedFunction
Definition: RuntimeDyld.h:66
llvm::RuntimeDyldImpl::relocationNeedsGot
virtual bool relocationNeedsGot(const RelocationRef &R) const
Definition: RuntimeDyldImpl.h:439
llvm::RuntimeDyldImpl::IsMipsN32ABI
bool IsMipsN32ABI
Definition: RuntimeDyldImpl.h:291
llvm::RuntimeDyldImpl::NotifyStubEmitted
NotifyStubEmittedFunction NotifyStubEmitted
Definition: RuntimeDyldImpl.h:312
llvm::RelocationEntry::SectionPair::SectionB
uint32_t SectionB
Definition: RuntimeDyldImpl.h:134
Triple.h
llvm::size
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1532
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:228
uint32_t
Mutex.h
llvm::SectionEntry::getSize
size_t getSize() const
Definition: RuntimeDyldImpl.h:94
llvm::RelocationValueRef::operator<
bool operator<(const RelocationValueRef &Other) const
Definition: RuntimeDyldImpl.h:203
RTDyldMemoryManager.h
llvm::SymbolTableEntry
Symbol info for RuntimeDyld.
Definition: RuntimeDyldImpl.h:217
name
static const char * name
Definition: SVEIntrinsicOpts.cpp:78
llvm::JITSymbolResolver
Symbol resolution interface.
Definition: JITSymbol.h:371
llvm::AMDGPU::HSAMD::Kernel::Key::SymbolName
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
Definition: AMDGPUMetadata.h:381
llvm::SectionEntry::advanceStubOffset
void advanceStubOffset(unsigned StubSize)
Definition: RuntimeDyldImpl.h:107
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
std
Definition: BitVector.h:838
uint16_t
llvm::SymbolTableEntry::getFlags
JITSymbolFlags getFlags() const
Definition: RuntimeDyldImpl.h:228
llvm::object::OwningBinary
Definition: RuntimeDyld.h:36
llvm::RuntimeDyld::LoadedObjectInfo
Information about the loaded object.
Definition: RuntimeDyld.h:69
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::RuntimeDyldImpl::RelocationList
SmallVector< RelocationEntry, 64 > RelocationList
Definition: RuntimeDyldImpl.h:274
llvm::RuntimeDyldImpl::getSymbolTable
std::map< StringRef, JITEvaluatedSymbol > getSymbolTable() const
Definition: RuntimeDyldImpl.h:527
llvm::SectionEntry::getLoadAddressWithOffset
uint64_t getLoadAddressWithOffset(unsigned OffsetBytes) const
Return the load address of this section with an offset.
Definition: RuntimeDyldImpl.h:100
llvm::SectionEntry::getLoadAddress
uint64_t getLoadAddress() const
Definition: RuntimeDyldImpl.h:96
llvm::SectionEntry::getName
StringRef getName() const
Definition: RuntimeDyldImpl.h:84
llvm::RuntimeDyldImpl::hasError
bool hasError()
Definition: RuntimeDyldImpl.h:558
This
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical This
Definition: README.txt:418
llvm::RuntimeDyldImpl::Arch
Triple::ArchType Arch
Definition: RuntimeDyldImpl.h:288
SmallVector.h
llvm::RelocationEntry::Sections
SectionPair Sections
Definition: RuntimeDyldImpl.h:141
SymInfo
SymInfo contains information about symbol: it's address and section index which is -1LL for absolute ...
Definition: DWARFContext.cpp:1428
llvm::object::SymbolRef
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: ObjectFile.h:167
llvm::RuntimeDyldImpl::StubMap
std::map< RelocationValueRef, uintptr_t > StubMap
Definition: RuntimeDyldImpl.h:286
llvm::RuntimeDyldImpl::RuntimeDyldImpl
RuntimeDyldImpl(RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
Definition: RuntimeDyldImpl.h:449
llvm::object::RelocationRef
This is a value type class that represents a single relocation in the list of relocations in the obje...
Definition: ObjectFile.h:51
llvm::SymbolTableEntry::setOffset
void setOffset(uint64_t NewOffset)
Definition: RuntimeDyldImpl.h:226
llvm::RuntimeDyldImpl::setProcessAllSections
void setProcessAllSections(bool ProcessAllSections)
Definition: RuntimeDyldImpl.h:457
llvm::RuntimeDyldImpl::Relocations
std::unordered_map< unsigned, RelocationList > Relocations
Definition: RuntimeDyldImpl.h:278
llvm::RelocationValueRef
Definition: RuntimeDyldImpl.h:190
llvm::JITSymbolFlags::None
@ None
Definition: JITSymbol.h:80
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
Debug.h
llvm::RelocationEntry::RelType
uint32_t RelType
RelType - relocation type.
Definition: RuntimeDyldImpl.h:126
llvm::RuntimeDyldImpl::writeInt16BE
void writeInt16BE(uint8_t *Addr, uint16_t Value)
Definition: RuntimeDyldImpl.h:320
llvm::RuntimeDyldImpl::GlobalSymbolTable
RTDyldSymbolTable GlobalSymbolTable
Definition: RuntimeDyldImpl.h:264
llvm::support::big
@ big
Definition: Endian.h:27
llvm::RuntimeDyldImpl::ObjSectionToIDMap
std::map< SectionRef, unsigned > ObjSectionToIDMap
Definition: RuntimeDyldImpl.h:261
llvm::object::resolveRelocation
uint64_t resolveRelocation(RelocationResolver Resolver, const RelocationRef &R, uint64_t S, uint64_t LocData)
Definition: RelocationResolver.cpp:736
SpecialSubKind::string
@ string
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1184
llvm::RuntimeDyld::MemoryManager
Memory Management.
Definition: RuntimeDyld.h:92