LLVM  14.0.0git
ELF_x86_64.cpp
Go to the documentation of this file.
1 //===---- ELF_x86_64.cpp -JIT linker implementation for ELF/x86-64 ----===//
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 // ELF/x86-64 jit-link implementation.
10 //
11 //===----------------------------------------------------------------------===//
12 
17 #include "llvm/Support/Endian.h"
18 
20 #include "EHFrameSupportImpl.h"
21 #include "ELFLinkGraphBuilder.h"
22 #include "JITLinkGeneric.h"
24 
25 #define DEBUG_TYPE "jitlink"
26 
27 using namespace llvm;
28 using namespace llvm::jitlink;
29 using namespace llvm::jitlink::ELF_x86_64_Edges;
30 
31 namespace {
32 
33 constexpr StringRef ELFGOTSectionName = "$__GOT";
34 constexpr StringRef ELFGOTSymbolName = "_GLOBAL_OFFSET_TABLE_";
35 
36 class PerGraphGOTAndPLTStubsBuilder_ELF_x86_64
38  PerGraphGOTAndPLTStubsBuilder_ELF_x86_64> {
39 public:
40  static const uint8_t NullGOTEntryContent[8];
41  static const uint8_t StubContent[6];
42 
44  PerGraphGOTAndPLTStubsBuilder_ELF_x86_64>::PerGraphGOTAndPLTStubsBuilder;
45 
46  bool isGOTEdgeToFix(Edge &E) const {
47  if (E.getKind() == GOTOFF64) {
48  // We need to make sure that the GOT section exists, but don't otherwise
49  // need to fix up this edge.
50  getGOTSection();
51  return false;
52  }
53 
54  return E.getKind() == PCRel32GOT || E.getKind() == PCRel32GOTLoad ||
55  E.getKind() == PCRel64GOT || E.getKind() == GOT64;
56  }
57 
58  Symbol &createGOTEntry(Symbol &Target) {
59  auto &GOTEntryBlock = G.createContentBlock(
60  getGOTSection(), getGOTEntryBlockContent(), 0, 8, 0);
61  GOTEntryBlock.addEdge(Pointer64, 0, Target, 0);
62  return G.addAnonymousSymbol(GOTEntryBlock, 0, 8, false, false);
63  }
64 
65  void fixGOTEdge(Edge &E, Symbol &GOTEntry) {
66  // If this is a PCRel32GOT/PCRel64GOT then change it to an ordinary
67  // PCRel32/PCRel64. If it is a PCRel32GOTLoad then leave it as-is for now:
68  // We will use the kind to check for GOT optimization opportunities in the
69  // optimizeMachO_x86_64_GOTAndStubs pass below.
70  // If it's a GOT64 leave it as is.
71  switch (E.getKind()) {
72  case PCRel32GOT:
73  E.setKind(PCRel32);
74  break;
75  case PCRel64GOT:
76  E.setKind(PCRel64);
77  break;
78  case GOT64:
79  break;
80  case PCRel32GOTLoad:
81  break;
82  default:
83  llvm_unreachable("Unexpected GOT edge kind");
84  }
85 
86  E.setTarget(GOTEntry);
87  // Leave the edge addend as-is.
88  }
89 
90  bool isExternalBranchEdge(Edge &E) {
91  return E.getKind() == Branch32 && !E.getTarget().isDefined();
92  }
93 
94  Symbol &createPLTStub(Symbol &Target) {
95  auto &StubContentBlock =
96  G.createContentBlock(getStubsSection(), getStubBlockContent(), 0, 1, 0);
97  // Re-use GOT entries for stub targets.
98  auto &GOTEntrySymbol = getGOTEntry(Target);
99  StubContentBlock.addEdge(PCRel32, 2, GOTEntrySymbol, -4);
100  return G.addAnonymousSymbol(StubContentBlock, 0, 6, true, false);
101  }
102 
103  void fixPLTEdge(Edge &E, Symbol &Stub) {
104  assert(E.getKind() == Branch32 && "Not a Branch32 edge?");
105 
106  // Set the edge kind to Branch32ToStub. We will use this to check for stub
107  // optimization opportunities in the optimize ELF_x86_64_GOTAndStubs pass
108  // below.
109  E.setKind(Branch32ToStub);
110  E.setTarget(Stub);
111  }
112 
113 private:
114  Section &getGOTSection() const {
115  if (!GOTSection)
116  GOTSection = &G.createSection(ELFGOTSectionName, sys::Memory::MF_READ);
117  return *GOTSection;
118  }
119 
120  Section &getStubsSection() const {
121  if (!StubsSection) {
122  auto StubsProt = static_cast<sys::Memory::ProtectionFlags>(
124  StubsSection = &G.createSection("$__STUBS", StubsProt);
125  }
126  return *StubsSection;
127  }
128 
129  ArrayRef<char> getGOTEntryBlockContent() {
130  return {reinterpret_cast<const char *>(NullGOTEntryContent),
131  sizeof(NullGOTEntryContent)};
132  }
133 
134  ArrayRef<char> getStubBlockContent() {
135  return {reinterpret_cast<const char *>(StubContent), sizeof(StubContent)};
136  }
137 
138  mutable Section *GOTSection = nullptr;
139  mutable Section *StubsSection = nullptr;
140 };
141 
142 } // namespace
143 
144 const uint8_t PerGraphGOTAndPLTStubsBuilder_ELF_x86_64::NullGOTEntryContent[8] =
145  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
146 const uint8_t PerGraphGOTAndPLTStubsBuilder_ELF_x86_64::StubContent[6] = {
147  0xFF, 0x25, 0x00, 0x00, 0x00, 0x00};
148 
150  LLVM_DEBUG(dbgs() << "Optimizing GOT entries and stubs:\n");
151 
152  for (auto *B : G.blocks())
153  for (auto &E : B->edges())
154  if (E.getKind() == PCRel32GOTLoad) {
155  // Replace GOT load with LEA only for MOVQ instructions.
156  constexpr uint8_t MOVQRIPRel[] = {0x48, 0x8b};
157  if (E.getOffset() < 3 ||
158  strncmp(B->getContent().data() + E.getOffset() - 3,
159  reinterpret_cast<const char *>(MOVQRIPRel), 2) != 0)
160  continue;
161 
162  auto &GOTBlock = E.getTarget().getBlock();
163  assert(GOTBlock.getSize() == G.getPointerSize() &&
164  "GOT entry block should be pointer sized");
165  assert(GOTBlock.edges_size() == 1 &&
166  "GOT entry should only have one outgoing edge");
167 
168  auto &GOTTarget = GOTBlock.edges().begin()->getTarget();
169  JITTargetAddress EdgeAddr = B->getAddress() + E.getOffset();
170  JITTargetAddress TargetAddr = GOTTarget.getAddress();
171 
172  int64_t Displacement = TargetAddr - EdgeAddr + 4;
173  if (Displacement >= std::numeric_limits<int32_t>::min() &&
174  Displacement <= std::numeric_limits<int32_t>::max()) {
175  // Change the edge kind as we don't go through GOT anymore. This is
176  // for formal correctness only. Technically, the two relocation kinds
177  // are resolved the same way.
178  E.setKind(PCRel32);
179  E.setTarget(GOTTarget);
180  auto *BlockData = reinterpret_cast<uint8_t *>(
181  const_cast<char *>(B->getContent().data()));
182  BlockData[E.getOffset() - 2] = 0x8d;
183  LLVM_DEBUG({
184  dbgs() << " Replaced GOT load wih LEA:\n ";
185  printEdge(dbgs(), *B, E, getELFX86RelocationKindName(E.getKind()));
186  dbgs() << "\n";
187  });
188  }
189  } else if (E.getKind() == Branch32ToStub) {
190  auto &StubBlock = E.getTarget().getBlock();
191  assert(
192  StubBlock.getSize() ==
193  sizeof(PerGraphGOTAndPLTStubsBuilder_ELF_x86_64::StubContent) &&
194  "Stub block should be stub sized");
195  assert(StubBlock.edges_size() == 1 &&
196  "Stub block should only have one outgoing edge");
197 
198  auto &GOTBlock = StubBlock.edges().begin()->getTarget().getBlock();
199  assert(GOTBlock.getSize() == G.getPointerSize() &&
200  "GOT block should be pointer sized");
201  assert(GOTBlock.edges_size() == 1 &&
202  "GOT block should only have one outgoing edge");
203 
204  auto &GOTTarget = GOTBlock.edges().begin()->getTarget();
205  JITTargetAddress EdgeAddr = B->getAddress() + E.getOffset();
206  JITTargetAddress TargetAddr = GOTTarget.getAddress();
207 
208  int64_t Displacement = TargetAddr - EdgeAddr + 4;
209  if (Displacement >= std::numeric_limits<int32_t>::min() &&
210  Displacement <= std::numeric_limits<int32_t>::max()) {
211  E.setKind(Branch32);
212  E.setTarget(GOTTarget);
213  LLVM_DEBUG({
214  dbgs() << " Replaced stub branch with direct branch:\n ";
215  printEdge(dbgs(), *B, E, getELFX86RelocationKindName(E.getKind()));
216  dbgs() << "\n";
217  });
218  }
219  }
220 
221  return Error::success();
222 }
223 
224 static const char *getELFX86_64RelocName(uint32_t Type) {
225  switch (Type) {
226 #define ELF_RELOC(Name, Number) \
227  case Number: \
228  return #Name;
229 #include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
230 #undef ELF_RELOC
231  }
232  return "Unrecognized ELF/x86-64 relocation type";
233 }
234 
235 namespace llvm {
236 namespace jitlink {
237 
238 // This should become a template as the ELFFile is so a lot of this could become
239 // generic
240 class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
241 private:
242 
244  getRelocationKind(const uint32_t Type) {
245  switch (Type) {
246  case ELF::R_X86_64_PC32:
248  case ELF::R_X86_64_PC64:
249  case ELF::R_X86_64_GOTPC64:
251  case ELF::R_X86_64_64:
253  case ELF::R_X86_64_GOTPCREL:
254  case ELF::R_X86_64_GOTPCRELX:
255  case ELF::R_X86_64_REX_GOTPCRELX:
257  case ELF::R_X86_64_GOTPCREL64:
259  case ELF::R_X86_64_GOT64:
261  case ELF::R_X86_64_GOTOFF64:
263  case ELF::R_X86_64_PLT32:
265  }
266  return make_error<JITLinkError>("Unsupported x86-64 relocation type " +
267  formatv("{0:d}: ", Type) +
269  }
270 
271  Error addRelocations() override {
272  LLVM_DEBUG(dbgs() << "Adding relocations\n");
273  // TODO a partern is forming of iterate some sections but only give me
274  // ones I am interested, i should abstract that concept some where
275  for (auto &SecRef : Sections) {
276  if (SecRef.sh_type != ELF::SHT_RELA && SecRef.sh_type != ELF::SHT_REL)
277  continue;
278  // TODO can the elf obj file do this for me?
279  if (SecRef.sh_type == ELF::SHT_REL)
280  return make_error<llvm::StringError>("Shouldn't have REL in x64",
282 
283  auto RelSectName = Obj.getSectionName(SecRef);
284  if (!RelSectName)
285  return RelSectName.takeError();
286 
287  LLVM_DEBUG({
288  dbgs() << "Adding relocations from section " << *RelSectName << "\n";
289  });
290 
291  auto UpdateSection = Obj.getSection(SecRef.sh_info);
292  if (!UpdateSection)
293  return UpdateSection.takeError();
294 
295  auto UpdateSectionName = Obj.getSectionName(**UpdateSection);
296  if (!UpdateSectionName)
297  return UpdateSectionName.takeError();
298 
299  // Don't process relocations for debug sections.
300  if (isDwarfSection(*UpdateSectionName)) {
301  LLVM_DEBUG({
302  dbgs() << " Target is dwarf section " << *UpdateSectionName
303  << ". Skipping.\n";
304  });
305  continue;
306  } else
307  LLVM_DEBUG({
308  dbgs() << " For target section " << *UpdateSectionName << "\n";
309  });
310 
311  auto JITSection = G->findSectionByName(*UpdateSectionName);
312  if (!JITSection)
313  return make_error<llvm::StringError>(
314  "Refencing a a section that wasn't added to graph" +
315  *UpdateSectionName,
317 
318  auto Relocations = Obj.relas(SecRef);
319  if (!Relocations)
320  return Relocations.takeError();
321 
322  for (const auto &Rela : *Relocations) {
323  auto Type = Rela.getType(false);
324 
325  LLVM_DEBUG({
326  dbgs() << "Relocation Type: " << Type << "\n"
327  << "Name: " << Obj.getRelocationTypeName(Type) << "\n";
328  });
329  auto SymbolIndex = Rela.getSymbol(false);
330  auto Symbol = Obj.getRelocationSymbol(Rela, SymTabSec);
331  if (!Symbol)
332  return Symbol.takeError();
333 
334  auto BlockToFix = *(JITSection->blocks().begin());
335  auto *TargetSymbol = getGraphSymbol(SymbolIndex);
336 
337  if (!TargetSymbol) {
338  return make_error<llvm::StringError>(
339  "Could not find symbol at given index, did you add it to "
340  "JITSymbolTable? index: " +
341  std::to_string(SymbolIndex) +
342  ", shndx: " + std::to_string((*Symbol)->st_shndx) +
343  " Size of table: " + std::to_string(GraphSymbols.size()),
345  }
346  uint64_t Addend = Rela.r_addend;
347  JITTargetAddress FixupAddress =
348  (*UpdateSection)->sh_addr + Rela.r_offset;
349 
350  LLVM_DEBUG({
351  dbgs() << "Processing relocation at "
352  << format("0x%016" PRIx64, FixupAddress) << "\n";
353  });
354  auto Kind = getRelocationKind(Type);
355  if (!Kind)
356  return Kind.takeError();
357 
358  LLVM_DEBUG({
359  Edge GE(*Kind, FixupAddress - BlockToFix->getAddress(), *TargetSymbol,
360  Addend);
361  printEdge(dbgs(), *BlockToFix, GE,
363  dbgs() << "\n";
364  });
365  BlockToFix->addEdge(*Kind, FixupAddress - BlockToFix->getAddress(),
366  *TargetSymbol, Addend);
367  }
368  }
369  return Error::success();
370  }
371 
372 public:
375  : ELFLinkGraphBuilder(Obj, Triple("x86_64-unknown-linux"), FileName,
377 };
378 
379 class ELFJITLinker_x86_64 : public JITLinker<ELFJITLinker_x86_64> {
381 
382 public:
383  ELFJITLinker_x86_64(std::unique_ptr<JITLinkContext> Ctx,
384  std::unique_ptr<LinkGraph> G,
385  PassConfiguration PassConfig)
386  : JITLinker(std::move(Ctx), std::move(G), std::move(PassConfig)) {
387  getPassConfig().PostAllocationPasses.push_back(
388  [this](LinkGraph &G) { return getOrCreateGOTSymbol(G); });
389  }
390 
391 private:
392  Symbol *GOTSymbol = nullptr;
393 
394  Error getOrCreateGOTSymbol(LinkGraph &G) {
395  auto DefineExternalGOTSymbolIfPresent =
397  [&](LinkGraph &LG, Symbol &Sym) -> SectionRangeSymbolDesc {
398  if (Sym.getName() == ELFGOTSymbolName)
399  if (auto *GOTSection = G.findSectionByName(ELFGOTSectionName)) {
400  GOTSymbol = &Sym;
401  return {*GOTSection, true};
402  }
403  return {};
404  });
405 
406  // Try to attach _GLOBAL_OFFSET_TABLE_ to the GOT if it's defined as an
407  // external.
408  if (auto Err = DefineExternalGOTSymbolIfPresent(G))
409  return Err;
410 
411  // If we succeeded then we're done.
412  if (GOTSymbol)
413  return Error::success();
414 
415  // Otherwise look for a GOT section: If it already has a start symbol we'll
416  // record it, otherwise we'll create our own.
417  // If there's a GOT section but we didn't find an external GOT symbol...
418  if (auto *GOTSection = G.findSectionByName(ELFGOTSectionName)) {
419 
420  // Check for an existing defined symbol.
421  for (auto *Sym : GOTSection->symbols())
422  if (Sym->getName() == ELFGOTSymbolName) {
423  GOTSymbol = Sym;
424  return Error::success();
425  }
426 
427  // If there's no defined symbol then create one.
428  SectionRange SR(*GOTSection);
429  if (SR.empty())
430  GOTSymbol = &G.addAbsoluteSymbol(ELFGOTSymbolName, 0, 0,
432  else
433  GOTSymbol =
434  &G.addDefinedSymbol(*SR.getFirstBlock(), 0, ELFGOTSymbolName, 0,
435  Linkage::Strong, Scope::Local, false, true);
436  }
437 
438  return Error::success();
439  }
440 
441  Error applyFixup(LinkGraph &G, Block &B, const Edge &E) const {
442  using namespace ELF_x86_64_Edges;
443  using namespace llvm::support;
444 
445  char *BlockWorkingMem = B.getAlreadyMutableContent().data();
446  char *FixupPtr = BlockWorkingMem + E.getOffset();
447  JITTargetAddress FixupAddress = B.getAddress() + E.getOffset();
448  switch (E.getKind()) {
453  int64_t Value = E.getTarget().getAddress() + E.getAddend() - FixupAddress;
455  *(little32_t *)FixupPtr = Value;
456  else
457  return makeTargetOutOfRangeError(G, B, E);
458  break;
459  }
461  int64_t Value = E.getTarget().getAddress() + E.getAddend() - FixupAddress;
462  *(little64_t *)FixupPtr = Value;
463  break;
464  }
466  int64_t Value = E.getTarget().getAddress() + E.getAddend();
467  *(ulittle64_t *)FixupPtr = Value;
468  break;
469  }
471  int64_t Value = E.getTarget().getAddress() + E.getAddend() - FixupAddress;
473  *(little32_t *)FixupPtr = Value;
474  else
475  return makeTargetOutOfRangeError(G, B, E);
476  break;
477  }
479  int64_t Value = E.getTarget().getAddress() + E.getAddend() - FixupAddress;
480  *(little64_t *)FixupPtr = Value;
481  break;
482  }
484  int64_t Value = FixupAddress - E.getTarget().getAddress() + E.getAddend();
486  *(little32_t *)FixupPtr = Value;
487  else
488  return makeTargetOutOfRangeError(G, B, E);
489  break;
490  }
492  int64_t Value = FixupAddress - E.getTarget().getAddress() + E.getAddend();
493  *(little64_t *)FixupPtr = Value;
494  break;
495  }
498  // GOT64: Offset of GOT entry within GOT.
499  // GOTOFF64: Offset from GOT base to target.
500  // The expressions are the same in both cases, but in the GOT64 case the
501  // edge will have been fixed to point at the GOT entry, and in the
502  // GOTOFF64 case it will still point at the original target.
503  assert(GOTSymbol && "No GOT section symbol");
504  int64_t Value =
505  E.getTarget().getAddress() - GOTSymbol->getAddress() + E.getAddend();
506  *(little64_t *)FixupPtr = Value;
507  break;
508  }
509  default:
510  LLVM_DEBUG({
511  dbgs() << "Bad edge: " << getELFX86RelocationKindName(E.getKind())
512  << "\n";
513  });
514  llvm_unreachable("Unsupported relocation");
515  }
516  return Error::success();
517  }
518 };
519 
522  LLVM_DEBUG({
523  dbgs() << "Building jitlink graph for new input "
524  << ObjectBuffer.getBufferIdentifier() << "...\n";
525  });
526 
527  auto ELFObj = object::ObjectFile::createELFObjectFile(ObjectBuffer);
528  if (!ELFObj)
529  return ELFObj.takeError();
530 
531  auto &ELFObjFile = cast<object::ELFObjectFile<object::ELF64LE>>(**ELFObj);
532  return ELFLinkGraphBuilder_x86_64((*ELFObj)->getFileName(),
533  ELFObjFile.getELFFile())
534  .buildGraph();
535 }
536 
539  constexpr StringRef StartSymbolPrefix = "__start";
540  constexpr StringRef EndSymbolPrefix = "__end";
541 
542  auto SymName = Sym.getName();
543  if (SymName.startswith(StartSymbolPrefix)) {
544  if (auto *Sec =
545  G.findSectionByName(SymName.drop_front(StartSymbolPrefix.size())))
546  return {*Sec, true};
547  } else if (SymName.startswith(EndSymbolPrefix)) {
548  if (auto *Sec =
549  G.findSectionByName(SymName.drop_front(EndSymbolPrefix.size())))
550  return {*Sec, false};
551  }
552  return {};
553 }
554 
555 void link_ELF_x86_64(std::unique_ptr<LinkGraph> G,
556  std::unique_ptr<JITLinkContext> Ctx) {
557  PassConfiguration Config;
558 
559  if (Ctx->shouldAddDefaultTargetPasses(G->getTargetTriple())) {
560 
561  Config.PrePrunePasses.push_back(EHFrameSplitter(".eh_frame"));
562  Config.PrePrunePasses.push_back(EHFrameEdgeFixer(
563  ".eh_frame", G->getPointerSize(), Delta64, Delta32, NegDelta32));
564  Config.PrePrunePasses.push_back(EHFrameNullTerminator(".eh_frame"));
565 
566  // Construct a JITLinker and run the link function.
567  // Add a mark-live pass.
568  if (auto MarkLive = Ctx->getMarkLivePass(G->getTargetTriple()))
569  Config.PrePrunePasses.push_back(std::move(MarkLive));
570  else
571  Config.PrePrunePasses.push_back(markAllSymbolsLive);
572 
573  // Add an in-place GOT/Stubs pass.
574  Config.PostPrunePasses.push_back(
575  PerGraphGOTAndPLTStubsBuilder_ELF_x86_64::asPass);
576 
577  // Resolve any external section start / end symbols.
578  Config.PostAllocationPasses.push_back(
581 
582  // Add GOT/Stubs optimizer pass.
584  }
585 
586  if (auto Err = Ctx->modifyPassConfig(*G, Config))
587  return Ctx->notifyFailed(std::move(Err));
588 
590 }
592  switch (R) {
593  case Branch32:
594  return "Branch32";
595  case Branch32ToStub:
596  return "Branch32ToStub";
597  case Pointer32:
598  return "Pointer32";
599  case Pointer64:
600  return "Pointer64";
601  case Pointer64Anon:
602  return "Pointer64Anon";
603  case PCRel32:
604  return "PCRel32";
605  case PCRel32Minus1:
606  return "PCRel32Minus1";
607  case PCRel32Minus2:
608  return "PCRel32Minus2";
609  case PCRel32Minus4:
610  return "PCRel32Minus4";
611  case PCRel32Anon:
612  return "PCRel32Anon";
613  case PCRel32Minus1Anon:
614  return "PCRel32Minus1Anon";
615  case PCRel32Minus2Anon:
616  return "PCRel32Minus2Anon";
617  case PCRel32Minus4Anon:
618  return "PCRel32Minus4Anon";
619  case PCRel32GOTLoad:
620  return "PCRel32GOTLoad";
621  case PCRel32GOT:
622  return "PCRel32GOT";
623  case PCRel32TLV:
624  return "PCRel32TLV";
625  case Delta32:
626  return "Delta32";
627  case Delta64:
628  return "Delta64";
629  case NegDelta32:
630  return "NegDelta32";
631  case NegDelta64:
632  return "NegDelta64";
633  }
634  return getGenericEdgeKindName(static_cast<Edge::Kind>(R));
635 }
636 } // end namespace jitlink
637 } // end namespace llvm
llvm::sys::Memory::MF_READ
@ MF_READ
Definition: Memory.h:55
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::support::detail::packed_endian_specific_integral
Definition: Endian.h:206
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
DefineExternalSectionStartAndEndSymbols.h
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::ELF::SHT_RELA
@ SHT_RELA
Definition: ELF.h:913
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:122
getELFX86_64RelocName
static const char * getELFX86_64RelocName(uint32_t Type)
Definition: ELF_x86_64.cpp:224
llvm::RISCVFenceField::R
@ R
Definition: RISCVBaseInfo.h:180
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::formatv
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
Definition: FormatVariadic.h:250
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::sys::Memory::ProtectionFlags
ProtectionFlags
Definition: Memory.h:54
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::object::ObjectFile::createELFObjectFile
static Expected< std::unique_ptr< ObjectFile > > createELFObjectFile(MemoryBufferRef Object, bool InitContent=true)
Definition: ELFObjectFile.cpp:72
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::sys::Memory::MF_EXEC
@ MF_EXEC
Definition: Memory.h:57
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
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
optimizeELF_x86_64_GOTAndStubs
static Error optimizeELF_x86_64_GOTAndStubs(LinkGraph &G)
Definition: ELF_x86_64.cpp:149
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1605
ELF_x86_64.h
llvm::AArch64CC::GE
@ GE
Definition: AArch64BaseInfo.h:246
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
if
if(llvm_vc STREQUAL "") set(fake_version_inc "$
Definition: CMakeLists.txt:14
uint32_t
llvm::format
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:124
x86_64.h
ELFObjectFile.h
PerGraphGOTAndPLTStubsBuilder.h
std
Definition: BitVector.h:838
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:77
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::support
Definition: Endian.h:25
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
EHFrameSupportImpl.h
llvm::JITTargetAddress
uint64_t JITTargetAddress
Represents an address in the target process's address space.
Definition: JITSymbol.h:42
llvm::to_string
std::string to_string(const T &Value)
Definition: ScopedPrinter.h:63
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340
LLVM_LIKELY
#define LLVM_LIKELY(EXPR)
Definition: Compiler.h:219
llvm::MemoryBufferRef::getBufferIdentifier
StringRef getBufferIdentifier() const
Definition: MemoryBufferRef.h:33
ELFLinkGraphBuilder.h
llvm::ELF::SHT_REL
@ SHT_REL
Definition: ELF.h:918
isDwarfSection
static bool isDwarfSection(const MCObjectFileInfo *FI, const MCSection *Section)
Definition: NVPTXTargetStreamer.cpp:42
Endian.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::object::ELFFile
Definition: ELF.h:98
JITLinkGeneric.h