LLVM  13.0.0git
ELF.cpp
Go to the documentation of this file.
1 //===- ELF.cpp - ELF object file implementation ---------------------------===//
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 #include "llvm/Object/ELF.h"
10 #include "llvm/BinaryFormat/ELF.h"
12 
13 using namespace llvm;
14 using namespace object;
15 
16 #define STRINGIFY_ENUM_CASE(ns, name) \
17  case ns::name: \
18  return #name;
19 
20 #define ELF_RELOC(name, value) STRINGIFY_ENUM_CASE(ELF, name)
21 
23  uint32_t Type) {
24  switch (Machine) {
25  case ELF::EM_X86_64:
26  switch (Type) {
27 #include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
28  default:
29  break;
30  }
31  break;
32  case ELF::EM_386:
33  case ELF::EM_IAMCU:
34  switch (Type) {
35 #include "llvm/BinaryFormat/ELFRelocs/i386.def"
36  default:
37  break;
38  }
39  break;
40  case ELF::EM_MIPS:
41  switch (Type) {
42 #include "llvm/BinaryFormat/ELFRelocs/Mips.def"
43  default:
44  break;
45  }
46  break;
47  case ELF::EM_AARCH64:
48  switch (Type) {
49 #include "llvm/BinaryFormat/ELFRelocs/AArch64.def"
50  default:
51  break;
52  }
53  break;
54  case ELF::EM_ARM:
55  switch (Type) {
56 #include "llvm/BinaryFormat/ELFRelocs/ARM.def"
57  default:
58  break;
59  }
60  break;
63  switch (Type) {
64 #include "llvm/BinaryFormat/ELFRelocs/ARC.def"
65  default:
66  break;
67  }
68  break;
69  case ELF::EM_AVR:
70  switch (Type) {
71 #include "llvm/BinaryFormat/ELFRelocs/AVR.def"
72  default:
73  break;
74  }
75  break;
76  case ELF::EM_HEXAGON:
77  switch (Type) {
78 #include "llvm/BinaryFormat/ELFRelocs/Hexagon.def"
79  default:
80  break;
81  }
82  break;
83  case ELF::EM_LANAI:
84  switch (Type) {
85 #include "llvm/BinaryFormat/ELFRelocs/Lanai.def"
86  default:
87  break;
88  }
89  break;
90  case ELF::EM_PPC:
91  switch (Type) {
92 #include "llvm/BinaryFormat/ELFRelocs/PowerPC.def"
93  default:
94  break;
95  }
96  break;
97  case ELF::EM_PPC64:
98  switch (Type) {
99 #include "llvm/BinaryFormat/ELFRelocs/PowerPC64.def"
100  default:
101  break;
102  }
103  break;
104  case ELF::EM_RISCV:
105  switch (Type) {
106 #include "llvm/BinaryFormat/ELFRelocs/RISCV.def"
107  default:
108  break;
109  }
110  break;
111  case ELF::EM_S390:
112  switch (Type) {
113 #include "llvm/BinaryFormat/ELFRelocs/SystemZ.def"
114  default:
115  break;
116  }
117  break;
118  case ELF::EM_SPARC:
119  case ELF::EM_SPARC32PLUS:
120  case ELF::EM_SPARCV9:
121  switch (Type) {
122 #include "llvm/BinaryFormat/ELFRelocs/Sparc.def"
123  default:
124  break;
125  }
126  break;
127  case ELF::EM_AMDGPU:
128  switch (Type) {
129 #include "llvm/BinaryFormat/ELFRelocs/AMDGPU.def"
130  default:
131  break;
132  }
133  break;
134  case ELF::EM_BPF:
135  switch (Type) {
136 #include "llvm/BinaryFormat/ELFRelocs/BPF.def"
137  default:
138  break;
139  }
140  break;
141  case ELF::EM_MSP430:
142  switch (Type) {
143 #include "llvm/BinaryFormat/ELFRelocs/MSP430.def"
144  default:
145  break;
146  }
147  break;
148  case ELF::EM_VE:
149  switch (Type) {
150 #include "llvm/BinaryFormat/ELFRelocs/VE.def"
151  default:
152  break;
153  }
154  break;
155  case ELF::EM_CSKY:
156  switch (Type) {
157 #include "llvm/BinaryFormat/ELFRelocs/CSKY.def"
158  default:
159  break;
160  }
161  break;
162  default:
163  break;
164  }
165  return "Unknown";
166 }
167 
168 #undef ELF_RELOC
169 
171  switch (Machine) {
172  case ELF::EM_X86_64:
173  return ELF::R_X86_64_RELATIVE;
174  case ELF::EM_386:
175  case ELF::EM_IAMCU:
176  return ELF::R_386_RELATIVE;
177  case ELF::EM_MIPS:
178  break;
179  case ELF::EM_AARCH64:
180  return ELF::R_AARCH64_RELATIVE;
181  case ELF::EM_ARM:
182  return ELF::R_ARM_RELATIVE;
183  case ELF::EM_ARC_COMPACT:
185  return ELF::R_ARC_RELATIVE;
186  case ELF::EM_AVR:
187  break;
188  case ELF::EM_HEXAGON:
189  return ELF::R_HEX_RELATIVE;
190  case ELF::EM_LANAI:
191  break;
192  case ELF::EM_PPC:
193  break;
194  case ELF::EM_PPC64:
195  return ELF::R_PPC64_RELATIVE;
196  case ELF::EM_RISCV:
197  return ELF::R_RISCV_RELATIVE;
198  case ELF::EM_S390:
199  return ELF::R_390_RELATIVE;
200  case ELF::EM_SPARC:
201  case ELF::EM_SPARC32PLUS:
202  case ELF::EM_SPARCV9:
203  return ELF::R_SPARC_RELATIVE;
204  case ELF::EM_CSKY:
205  return ELF::R_CKCORE_RELATIVE;
206  case ELF::EM_AMDGPU:
207  break;
208  case ELF::EM_BPF:
209  break;
210  default:
211  break;
212  }
213  return 0;
214 }
215 
217  switch (Machine) {
218  case ELF::EM_ARM:
219  switch (Type) {
225  }
226  break;
227  case ELF::EM_HEXAGON:
228  switch (Type) { STRINGIFY_ENUM_CASE(ELF, SHT_HEX_ORDERED); }
229  break;
230  case ELF::EM_X86_64:
231  switch (Type) { STRINGIFY_ENUM_CASE(ELF, SHT_X86_64_UNWIND); }
232  break;
233  case ELF::EM_MIPS:
234  case ELF::EM_MIPS_RS3_LE:
235  switch (Type) {
240  }
241  break;
242  case ELF::EM_RISCV:
243  switch (Type) { STRINGIFY_ENUM_CASE(ELF, SHT_RISCV_ATTRIBUTES); }
244  break;
245  default:
246  break;
247  }
248 
249  switch (Type) {
285  default:
286  return "Unknown";
287  }
288 }
289 
290 template <class ELFT>
291 std::vector<typename ELFT::Rel>
292 ELFFile<ELFT>::decode_relrs(Elf_Relr_Range relrs) const {
293  // This function decodes the contents of an SHT_RELR packed relocation
294  // section.
295  //
296  // Proposal for adding SHT_RELR sections to generic-abi is here:
297  // https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg
298  //
299  // The encoded sequence of Elf64_Relr entries in a SHT_RELR section looks
300  // like [ AAAAAAAA BBBBBBB1 BBBBBBB1 ... AAAAAAAA BBBBBB1 ... ]
301  //
302  // i.e. start with an address, followed by any number of bitmaps. The address
303  // entry encodes 1 relocation. The subsequent bitmap entries encode up to 63
304  // relocations each, at subsequent offsets following the last address entry.
305  //
306  // The bitmap entries must have 1 in the least significant bit. The assumption
307  // here is that an address cannot have 1 in lsb. Odd addresses are not
308  // supported.
309  //
310  // Excluding the least significant bit in the bitmap, each non-zero bit in
311  // the bitmap represents a relocation to be applied to a corresponding machine
312  // word that follows the base address word. The second least significant bit
313  // represents the machine word immediately following the initial address, and
314  // each bit that follows represents the next word, in linear order. As such,
315  // a single bitmap can encode up to 31 relocations in a 32-bit object, and
316  // 63 relocations in a 64-bit object.
317  //
318  // This encoding has a couple of interesting properties:
319  // 1. Looking at any entry, it is clear whether it's an address or a bitmap:
320  // even means address, odd means bitmap.
321  // 2. Just a simple list of addresses is a valid encoding.
322 
323  Elf_Rel Rel;
324  Rel.r_info = 0;
325  Rel.setType(getRelativeRelocationType(), false);
326  std::vector<Elf_Rel> Relocs;
327 
328  // Word type: uint32_t for Elf32, and uint64_t for Elf64.
329  typedef typename ELFT::uint Word;
330 
331  // Word size in number of bytes.
332  const size_t WordSize = sizeof(Word);
333 
334  // Number of bits used for the relocation offsets bitmap.
335  // These many relative relocations can be encoded in a single entry.
336  const size_t NBits = 8*WordSize - 1;
337 
338  Word Base = 0;
339  for (const Elf_Relr &R : relrs) {
340  Word Entry = R;
341  if ((Entry&1) == 0) {
342  // Even entry: encodes the offset for next relocation.
343  Rel.r_offset = Entry;
344  Relocs.push_back(Rel);
345  // Set base offset for subsequent bitmap entries.
346  Base = Entry + WordSize;
347  continue;
348  }
349 
350  // Odd entry: encodes bitmap for relocations starting at base.
351  Word Offset = Base;
352  while (Entry != 0) {
353  Entry >>= 1;
354  if ((Entry&1) != 0) {
355  Rel.r_offset = Offset;
356  Relocs.push_back(Rel);
357  }
358  Offset += WordSize;
359  }
360 
361  // Advance base offset by NBits words.
362  Base += NBits * WordSize;
363  }
364 
365  return Relocs;
366 }
367 
368 template <class ELFT>
370 ELFFile<ELFT>::android_relas(const Elf_Shdr &Sec) const {
371  // This function reads relocations in Android's packed relocation format,
372  // which is based on SLEB128 and delta encoding.
373  Expected<ArrayRef<uint8_t>> ContentsOrErr = getSectionContents(Sec);
374  if (!ContentsOrErr)
375  return ContentsOrErr.takeError();
376  ArrayRef<uint8_t> Content = *ContentsOrErr;
377  if (Content.size() < 4 || Content[0] != 'A' || Content[1] != 'P' ||
378  Content[2] != 'S' || Content[3] != '2')
379  return createError("invalid packed relocation header");
380  DataExtractor Data(Content, isLE(), ELFT::Is64Bits ? 8 : 4);
381  DataExtractor::Cursor Cur(/*Offset=*/4);
382 
383  uint64_t NumRelocs = Data.getSLEB128(Cur);
384  uint64_t Offset = Data.getSLEB128(Cur);
385  uint64_t Addend = 0;
386 
387  if (!Cur)
388  return std::move(Cur.takeError());
389 
390  std::vector<Elf_Rela> Relocs;
391  Relocs.reserve(NumRelocs);
392  while (NumRelocs) {
393  uint64_t NumRelocsInGroup = Data.getSLEB128(Cur);
394  if (!Cur)
395  return std::move(Cur.takeError());
396  if (NumRelocsInGroup > NumRelocs)
397  return createError("relocation group unexpectedly large");
398  NumRelocs -= NumRelocsInGroup;
399 
400  uint64_t GroupFlags = Data.getSLEB128(Cur);
401  bool GroupedByInfo = GroupFlags & ELF::RELOCATION_GROUPED_BY_INFO_FLAG;
402  bool GroupedByOffsetDelta = GroupFlags & ELF::RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG;
403  bool GroupedByAddend = GroupFlags & ELF::RELOCATION_GROUPED_BY_ADDEND_FLAG;
404  bool GroupHasAddend = GroupFlags & ELF::RELOCATION_GROUP_HAS_ADDEND_FLAG;
405 
406  uint64_t GroupOffsetDelta;
407  if (GroupedByOffsetDelta)
408  GroupOffsetDelta = Data.getSLEB128(Cur);
409 
410  uint64_t GroupRInfo;
411  if (GroupedByInfo)
412  GroupRInfo = Data.getSLEB128(Cur);
413 
414  if (GroupedByAddend && GroupHasAddend)
415  Addend += Data.getSLEB128(Cur);
416 
417  if (!GroupHasAddend)
418  Addend = 0;
419 
420  for (uint64_t I = 0; Cur && I != NumRelocsInGroup; ++I) {
421  Elf_Rela R;
422  Offset += GroupedByOffsetDelta ? GroupOffsetDelta : Data.getSLEB128(Cur);
423  R.r_offset = Offset;
424  R.r_info = GroupedByInfo ? GroupRInfo : Data.getSLEB128(Cur);
425  if (GroupHasAddend && !GroupedByAddend)
426  Addend += Data.getSLEB128(Cur);
427  R.r_addend = Addend;
428  Relocs.push_back(R);
429  }
430  if (!Cur)
431  return std::move(Cur.takeError());
432  }
433 
434  return Relocs;
435 }
436 
437 template <class ELFT>
438 std::string ELFFile<ELFT>::getDynamicTagAsString(unsigned Arch,
439  uint64_t Type) const {
440 #define DYNAMIC_STRINGIFY_ENUM(tag, value) \
441  case value: \
442  return #tag;
443 
444 #define DYNAMIC_TAG(n, v)
445  switch (Arch) {
446  case ELF::EM_AARCH64:
447  switch (Type) {
448 #define AARCH64_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value)
449 #include "llvm/BinaryFormat/DynamicTags.def"
450 #undef AARCH64_DYNAMIC_TAG
451  }
452  break;
453 
454  case ELF::EM_HEXAGON:
455  switch (Type) {
456 #define HEXAGON_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value)
457 #include "llvm/BinaryFormat/DynamicTags.def"
458 #undef HEXAGON_DYNAMIC_TAG
459  }
460  break;
461 
462  case ELF::EM_MIPS:
463  switch (Type) {
464 #define MIPS_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value)
465 #include "llvm/BinaryFormat/DynamicTags.def"
466 #undef MIPS_DYNAMIC_TAG
467  }
468  break;
469 
470  case ELF::EM_PPC64:
471  switch (Type) {
472 #define PPC64_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value)
473 #include "llvm/BinaryFormat/DynamicTags.def"
474 #undef PPC64_DYNAMIC_TAG
475  }
476  break;
477  }
478 #undef DYNAMIC_TAG
479  switch (Type) {
480 // Now handle all dynamic tags except the architecture specific ones
481 #define AARCH64_DYNAMIC_TAG(name, value)
482 #define MIPS_DYNAMIC_TAG(name, value)
483 #define HEXAGON_DYNAMIC_TAG(name, value)
484 #define PPC64_DYNAMIC_TAG(name, value)
485 // Also ignore marker tags such as DT_HIOS (maps to DT_VERNEEDNUM), etc.
486 #define DYNAMIC_TAG_MARKER(name, value)
487 #define DYNAMIC_TAG(name, value) case value: return #name;
488 #include "llvm/BinaryFormat/DynamicTags.def"
489 #undef DYNAMIC_TAG
490 #undef AARCH64_DYNAMIC_TAG
491 #undef MIPS_DYNAMIC_TAG
492 #undef HEXAGON_DYNAMIC_TAG
493 #undef PPC64_DYNAMIC_TAG
494 #undef DYNAMIC_TAG_MARKER
495 #undef DYNAMIC_STRINGIFY_ENUM
496  default:
497  return "<unknown:>0x" + utohexstr(Type, true);
498  }
499 }
500 
501 template <class ELFT>
502 std::string ELFFile<ELFT>::getDynamicTagAsString(uint64_t Type) const {
503  return getDynamicTagAsString(getHeader().e_machine, Type);
504 }
505 
506 template <class ELFT>
508  ArrayRef<Elf_Dyn> Dyn;
509 
510  auto ProgramHeadersOrError = program_headers();
511  if (!ProgramHeadersOrError)
512  return ProgramHeadersOrError.takeError();
513 
514  for (const Elf_Phdr &Phdr : *ProgramHeadersOrError) {
515  if (Phdr.p_type == ELF::PT_DYNAMIC) {
516  Dyn = makeArrayRef(
517  reinterpret_cast<const Elf_Dyn *>(base() + Phdr.p_offset),
518  Phdr.p_filesz / sizeof(Elf_Dyn));
519  break;
520  }
521  }
522 
523  // If we can't find the dynamic section in the program headers, we just fall
524  // back on the sections.
525  if (Dyn.empty()) {
526  auto SectionsOrError = sections();
527  if (!SectionsOrError)
528  return SectionsOrError.takeError();
529 
530  for (const Elf_Shdr &Sec : *SectionsOrError) {
531  if (Sec.sh_type == ELF::SHT_DYNAMIC) {
532  Expected<ArrayRef<Elf_Dyn>> DynOrError =
533  getSectionContentsAsArray<Elf_Dyn>(Sec);
534  if (!DynOrError)
535  return DynOrError.takeError();
536  Dyn = *DynOrError;
537  break;
538  }
539  }
540 
541  if (!Dyn.data())
542  return ArrayRef<Elf_Dyn>();
543  }
544 
545  if (Dyn.empty())
546  // TODO: this error is untested.
547  return createError("invalid empty dynamic section");
548 
549  if (Dyn.back().d_tag != ELF::DT_NULL)
550  // TODO: this error is untested.
551  return createError("dynamic sections must be DT_NULL terminated");
552 
553  return Dyn;
554 }
555 
556 template <class ELFT>
558 ELFFile<ELFT>::toMappedAddr(uint64_t VAddr, WarningHandler WarnHandler) const {
559  auto ProgramHeadersOrError = program_headers();
560  if (!ProgramHeadersOrError)
561  return ProgramHeadersOrError.takeError();
562 
564 
565  for (const Elf_Phdr &Phdr : *ProgramHeadersOrError)
566  if (Phdr.p_type == ELF::PT_LOAD)
567  LoadSegments.push_back(const_cast<Elf_Phdr *>(&Phdr));
568 
569  auto SortPred = [](const Elf_Phdr_Impl<ELFT> *A,
570  const Elf_Phdr_Impl<ELFT> *B) {
571  return A->p_vaddr < B->p_vaddr;
572  };
573  if (!llvm::is_sorted(LoadSegments, SortPred)) {
574  if (Error E =
575  WarnHandler("loadable segments are unsorted by virtual address"))
576  return std::move(E);
577  llvm::stable_sort(LoadSegments, SortPred);
578  }
579 
580  const Elf_Phdr *const *I = llvm::upper_bound(
581  LoadSegments, VAddr, [](uint64_t VAddr, const Elf_Phdr_Impl<ELFT> *Phdr) {
582  return VAddr < Phdr->p_vaddr;
583  });
584 
585  if (I == LoadSegments.begin())
586  return createError("virtual address is not in any segment: 0x" +
587  Twine::utohexstr(VAddr));
588  --I;
589  const Elf_Phdr &Phdr = **I;
590  uint64_t Delta = VAddr - Phdr.p_vaddr;
591  if (Delta >= Phdr.p_filesz)
592  return createError("virtual address is not in any segment: 0x" +
593  Twine::utohexstr(VAddr));
594 
595  uint64_t Offset = Phdr.p_offset + Delta;
596  if (Offset >= getBufSize())
597  return createError("can't map virtual address 0x" +
598  Twine::utohexstr(VAddr) + " to the segment with index " +
599  Twine(&Phdr - (*ProgramHeadersOrError).data() + 1) +
600  ": the segment ends at 0x" +
601  Twine::utohexstr(Phdr.p_offset + Phdr.p_filesz) +
602  ", which is greater than the file size (0x" +
603  Twine::utohexstr(getBufSize()) + ")");
604 
605  return base() + Offset;
606 }
607 
608 template class llvm::object::ELFFile<ELF32LE>;
609 template class llvm::object::ELFFile<ELF32BE>;
610 template class llvm::object::ELFFile<ELF64LE>;
611 template class llvm::object::ELFFile<ELF64BE>;
llvm::ELF::SHT_GNU_ATTRIBUTES
@ SHT_GNU_ATTRIBUTES
Definition: ELF.h:887
llvm::ELF::SHT_PROGBITS
@ SHT_PROGBITS
Definition: ELF.h:849
llvm::ELF::SHT_LLVM_LINKER_OPTIONS
@ SHT_LLVM_LINKER_OPTIONS
Definition: ELF.h:874
llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:23
llvm::upper_bound
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1621
llvm::ELF::SHT_ARM_EXIDX
@ SHT_ARM_EXIDX
Definition: ELF.h:896
llvm::ELF::EM_MIPS_RS3_LE
@ EM_MIPS_RS3_LE
Definition: ELF.h:142
llvm::ELF::EM_ARM
@ EM_ARM
Definition: ELF.h:155
llvm::ELF::SHT_ANDROID_RELR
@ SHT_ANDROID_RELR
Definition: ELF.h:886
llvm::ELF::SHT_LLVM_ODRTAB
@ SHT_LLVM_ODRTAB
Definition: ELF.h:873
llvm::ELF::EM_VE
@ EM_VE
Definition: ELF.h:318
llvm::ELF::EM_SPARC
@ EM_SPARC
Definition: ELF.h:134
llvm::ELF::SHT_RELR
@ SHT_RELR
Definition: ELF.h:867
llvm::ELF::EM_SPARC32PLUS
@ EM_SPARC32PLUS
Definition: ELF.h:145
llvm::object::ELFFile::android_relas
Expected< std::vector< Elf_Rela > > android_relas(const Elf_Shdr &Sec) const
Definition: ELF.cpp:370
llvm::ELF::EM_HEXAGON
@ EM_HEXAGON
Definition: ELF.h:256
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::ELF::SHT_RELA
@ SHT_RELA
Definition: ELF.h:852
llvm::object::createError
static Error createError(const Twine &Err)
Definition: ELF.h:84
Content
T Content
Definition: ELFObjHandler.cpp:90
llvm::ELF::EM_MIPS
@ EM_MIPS
Definition: ELF.h:140
llvm::ELF::EM_RISCV
@ EM_RISCV
Definition: ELF.h:315
llvm::ELF::SHT_STRTAB
@ SHT_STRTAB
Definition: ELF.h:851
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
STRINGIFY_ENUM_CASE
#define STRINGIFY_ENUM_CASE(ns, name)
Definition: ELF.cpp:16
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::ELF::SHT_ANDROID_RELA
@ SHT_ANDROID_RELA
Definition: ELF.h:872
llvm::Data
@ Data
Definition: SIMachineScheduler.h:56
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:158
llvm::ArrayRef::data
const T * data() const
Definition: ArrayRef.h:160
llvm::ELF::SHT_GNU_HASH
@ SHT_GNU_HASH
Definition: ELF.h:888
uint
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint
Definition: README.txt:239
llvm::ELF::EM_AMDGPU
@ EM_AMDGPU
Definition: ELF.h:314
llvm::DataExtractor::Cursor::takeError
Error takeError()
Return error contained inside this Cursor, if any.
Definition: DataExtractor.h:75
llvm::ArrayRef::back
const T & back() const
back - Get the last element.
Definition: ArrayRef.h:172
ELF.h
llvm::ELF::SHT_RISCV_ATTRIBUTES
@ SHT_RISCV_ATTRIBUTES
Definition: ELF.h:914
llvm::ELF::EM_PPC
@ EM_PPC
Definition: ELF.h:147
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::ELF::SHT_SHLIB
@ SHT_SHLIB
Definition: ELF.h:858
llvm::ELF::EM_IAMCU
@ EM_IAMCU
Definition: ELF.h:138
llvm::ELF::PT_LOAD
@ PT_LOAD
Definition: ELF.h:1223
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::ELF::SHT_GROUP
@ SHT_GROUP
Definition: ELF.h:863
llvm::ELF::RELOCATION_GROUP_HAS_ADDEND_FLAG
@ RELOCATION_GROUP_HAS_ADDEND_FLAG
Definition: ELF.h:1590
llvm::ELF::SHT_LLVM_DEPENDENT_LIBRARIES
@ SHT_LLVM_DEPENDENT_LIBRARIES
Definition: ELF.h:878
llvm::ELF::EM_S390
@ EM_S390
Definition: ELF.h:149
llvm::ELF::EM_AARCH64
@ EM_AARCH64
Definition: ELF.h:279
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:176
llvm::ELF::RELOCATION_GROUPED_BY_ADDEND_FLAG
@ RELOCATION_GROUPED_BY_ADDEND_FLAG
Definition: ELF.h:1589
llvm::ELF::SHT_LLVM_PART_PHDR
@ SHT_LLVM_PART_PHDR
Definition: ELF.h:882
llvm::ELF::SHT_LLVM_CALL_GRAPH_PROFILE
@ SHT_LLVM_CALL_GRAPH_PROFILE
Definition: ELF.h:875
llvm::ELF::SHT_REL
@ SHT_REL
Definition: ELF.h:857
llvm::ELF::SHT_INIT_ARRAY
@ SHT_INIT_ARRAY
Definition: ELF.h:860
llvm::object::getELFRelocationTypeName
StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type)
Definition: ELF.cpp:22
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::object::Elf_Phdr_Impl
Definition: ELFTypes.h:32
llvm::Twine::utohexstr
static Twine utohexstr(const uint64_t &Val)
Definition: Twine.h:387
llvm::ELF::EM_AVR
@ EM_AVR
Definition: ELF.h:198
llvm::ELF::SHT_HEX_ORDERED
@ SHT_HEX_ORDERED
Definition: ELF.h:903
ELF.h
llvm::ELF::SHT_GNU_verneed
@ SHT_GNU_verneed
Definition: ELF.h:890
llvm::ELF::SHT_HASH
@ SHT_HASH
Definition: ELF.h:853
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::ELF::SHT_X86_64_UNWIND
@ SHT_X86_64_UNWIND
Definition: ELF.h:905
llvm::ELF::SHT_LLVM_SYMPART
@ SHT_LLVM_SYMPART
Definition: ELF.h:880
llvm::object::ELFFile::toMappedAddr
Expected< const uint8_t * > toMappedAddr(uint64_t VAddr, WarningHandler WarnHandler=&defaultWarningHandler) const
Definition: ELF.cpp:558
llvm::ELF::SHT_GNU_versym
@ SHT_GNU_versym
Definition: ELF.h:891
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::ELF::SHT_GNU_verdef
@ SHT_GNU_verdef
Definition: ELF.h:889
llvm::ELF::SHT_ARM_ATTRIBUTES
@ SHT_ARM_ATTRIBUTES
Definition: ELF.h:900
llvm::object::getELFSectionTypeName
StringRef getELFSectionTypeName(uint32_t Machine, uint32_t Type)
llvm::ELF::SHT_SYMTAB
@ SHT_SYMTAB
Definition: ELF.h:850
llvm::object::ELFFile::dynamicEntries
Expected< Elf_Dyn_Range > dynamicEntries() const
Definition: ELF.cpp:507
base
therefore end up llgh r3 lr r0 br r14 but truncating the load would lh r3 br r14 Functions ret i64 and ought to be implemented ngr r0 br r14 but two address optimizations reverse the order of the AND and ngr r2 lgr r0 br r14 CodeGen SystemZ and ll has several examples of this Out of range displacements are usually handled by loading the full address into a register In many cases it would be better to create an anchor point instead E g i64 base
Definition: README.txt:125
llvm::DataExtractor::Cursor
A class representing a position in a DataExtractor, as well as any error encountered during extractio...
Definition: DataExtractor.h:54
llvm::ELF::SHT_NOBITS
@ SHT_NOBITS
Definition: ELF.h:856
llvm::irsymtab::storage::Word
support::ulittle32_t Word
Definition: IRSymtab.h:51
llvm::ArrayRef< uint8_t >
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::ELF::EM_PPC64
@ EM_PPC64
Definition: ELF.h:148
llvm::ELF::SHT_LLVM_ADDRSIG
@ SHT_LLVM_ADDRSIG
Definition: ELF.h:876
uint32_t
llvm::ELF::SHT_LLVM_PART_EHDR
@ SHT_LLVM_PART_EHDR
Definition: ELF.h:881
llvm::object::ELFFile::getDynamicTagAsString
std::string getDynamicTagAsString(unsigned Arch, uint64_t Type) const
Definition: ELF.cpp:438
llvm::ELF::SHT_NOTE
@ SHT_NOTE
Definition: ELF.h:855
llvm::ELF::SHT_MIPS_REGINFO
@ SHT_MIPS_REGINFO
Definition: ELF.h:907
llvm::ELF::EM_ARC_COMPACT
@ EM_ARC_COMPACT
Definition: ELF.h:208
llvm::ELF::EM_SPARCV9
@ EM_SPARCV9
Definition: ELF.h:158
llvm::ELF::SHT_ARM_DEBUGOVERLAY
@ SHT_ARM_DEBUGOVERLAY
Definition: ELF.h:901
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
llvm::stable_sort
void stable_sort(R &&Range)
Definition: STLExtras.h:1633
llvm::ELF::RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG
@ RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG
Definition: ELF.h:1588
llvm::ELF::EM_X86_64
@ EM_X86_64
Definition: ELF.h:177
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::ELF::SHT_DYNSYM
@ SHT_DYNSYM
Definition: ELF.h:859
llvm::ELF::EM_386
@ EM_386
Definition: ELF.h:135
DataExtractor.h
llvm::ELF::EM_MSP430
@ EM_MSP430
Definition: ELF.h:221
llvm::is_sorted
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
Definition: STLExtras.h:1569
llvm::ELF::SHT_MIPS_DWARF
@ SHT_MIPS_DWARF
Definition: ELF.h:909
llvm::object::getELFRelativeRelocationType
uint32_t getELFRelativeRelocationType(uint32_t Machine)
Definition: ELF.cpp:170
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:474
llvm::ELF::SHT_ARM_PREEMPTMAP
@ SHT_ARM_PREEMPTMAP
Definition: ELF.h:898
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:557
llvm::DataExtractor
Definition: DataExtractor.h:41
Machine
COFF::MachineTypes Machine
Definition: COFFYAML.cpp:365
llvm::ELF::SHT_MIPS_OPTIONS
@ SHT_MIPS_OPTIONS
Definition: ELF.h:908
llvm::object::ELFFile::decode_relrs
std::vector< Elf_Rel > decode_relrs(Elf_Relr_Range relrs) const
Definition: ELF.cpp:292
llvm::ELF::SHT_SYMTAB_SHNDX
@ SHT_SYMTAB_SHNDX
Definition: ELF.h:864
llvm::ELF::EM_CSKY
@ EM_CSKY
Definition: ELF.h:319
llvm::ELF::SHT_ARM_OVERLAYSECTION
@ SHT_ARM_OVERLAYSECTION
Definition: ELF.h:902
llvm::ELF::RELOCATION_GROUPED_BY_INFO_FLAG
@ RELOCATION_GROUPED_BY_INFO_FLAG
Definition: ELF.h:1587
llvm::ELF::EM_BPF
@ EM_BPF
Definition: ELF.h:317
llvm::ELF::SHT_NULL
@ SHT_NULL
Definition: ELF.h:848
llvm::ELF::SHT_DYNAMIC
@ SHT_DYNAMIC
Definition: ELF.h:854
llvm::ELF::SHT_LLVM_BB_ADDR_MAP
@ SHT_LLVM_BB_ADDR_MAP
Definition: ELF.h:883
llvm::ELF::EM_ARC_COMPACT2
@ EM_ARC_COMPACT2
Definition: ELF.h:289
llvm::object::ELFFile
Definition: ELF.h:98
llvm::ELF::SHT_MIPS_ABIFLAGS
@ SHT_MIPS_ABIFLAGS
Definition: ELF.h:910
llvm::ELF::EM_LANAI
@ EM_LANAI
Definition: ELF.h:316
llvm::ELF::SHT_FINI_ARRAY
@ SHT_FINI_ARRAY
Definition: ELF.h:861
llvm::ELF::SHT_PREINIT_ARRAY
@ SHT_PREINIT_ARRAY
Definition: ELF.h:862
llvm::ELF::PT_DYNAMIC
@ PT_DYNAMIC
Definition: ELF.h:1224
llvm::ELF::SHT_ANDROID_REL
@ SHT_ANDROID_REL
Definition: ELF.h:871