LLVM  8.0.0svn
ELF.h
Go to the documentation of this file.
1 //===- ELF.h - ELF object file implementation -------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the ELFFile template class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_OBJECT_ELF_H
15 #define LLVM_OBJECT_ELF_H
16 
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/BinaryFormat/ELF.h"
21 #include "llvm/Object/ELFTypes.h"
22 #include "llvm/Object/Error.h"
23 #include "llvm/Support/Endian.h"
24 #include "llvm/Support/Error.h"
25 #include <cassert>
26 #include <cstddef>
27 #include <cstdint>
28 #include <limits>
29 #include <utility>
30 
31 namespace llvm {
32 namespace object {
33 
37 
38 // Subclasses of ELFFile may need this for template instantiation
39 inline std::pair<unsigned char, unsigned char>
41  if (Object.size() < ELF::EI_NIDENT)
42  return std::make_pair((uint8_t)ELF::ELFCLASSNONE,
43  (uint8_t)ELF::ELFDATANONE);
44  return std::make_pair((uint8_t)Object[ELF::EI_CLASS],
45  (uint8_t)Object[ELF::EI_DATA]);
46 }
47 
48 static inline Error createError(StringRef Err) {
49  return make_error<StringError>(Err, object_error::parse_failed);
50 }
51 
52 template <class ELFT>
53 class ELFFile {
54 public:
56  using uintX_t = typename ELFT::uint;
57  using Elf_Ehdr = typename ELFT::Ehdr;
58  using Elf_Shdr = typename ELFT::Shdr;
59  using Elf_Sym = typename ELFT::Sym;
60  using Elf_Dyn = typename ELFT::Dyn;
61  using Elf_Phdr = typename ELFT::Phdr;
62  using Elf_Rel = typename ELFT::Rel;
63  using Elf_Rela = typename ELFT::Rela;
64  using Elf_Relr = typename ELFT::Relr;
65  using Elf_Verdef = typename ELFT::Verdef;
66  using Elf_Verdaux = typename ELFT::Verdaux;
67  using Elf_Verneed = typename ELFT::Verneed;
68  using Elf_Vernaux = typename ELFT::Vernaux;
69  using Elf_Versym = typename ELFT::Versym;
70  using Elf_Hash = typename ELFT::Hash;
71  using Elf_GnuHash = typename ELFT::GnuHash;
72  using Elf_Nhdr = typename ELFT::Nhdr;
73  using Elf_Note = typename ELFT::Note;
74  using Elf_Note_Iterator = typename ELFT::NoteIterator;
75  using Elf_Dyn_Range = typename ELFT::DynRange;
76  using Elf_Shdr_Range = typename ELFT::ShdrRange;
77  using Elf_Sym_Range = typename ELFT::SymRange;
78  using Elf_Rel_Range = typename ELFT::RelRange;
79  using Elf_Rela_Range = typename ELFT::RelaRange;
80  using Elf_Relr_Range = typename ELFT::RelrRange;
81  using Elf_Phdr_Range = typename ELFT::PhdrRange;
82 
83  const uint8_t *base() const {
84  return reinterpret_cast<const uint8_t *>(Buf.data());
85  }
86 
87  size_t getBufSize() const { return Buf.size(); }
88 
89 private:
90  StringRef Buf;
91 
92  ELFFile(StringRef Object);
93 
94 public:
95  const Elf_Ehdr *getHeader() const {
96  return reinterpret_cast<const Elf_Ehdr *>(base());
97  }
98 
99  template <typename T>
101  template <typename T>
102  Expected<const T *> getEntry(const Elf_Shdr *Section, uint32_t Entry) const;
103 
104  Expected<StringRef> getStringTable(const Elf_Shdr *Section) const;
107  Elf_Shdr_Range Sections) const;
108 
109  Expected<ArrayRef<Elf_Word>> getSHNDXTable(const Elf_Shdr &Section) const;
111  Elf_Shdr_Range Sections) const;
112 
117 
118  const char *getDynamicTagAsString(unsigned Arch, uint64_t Type) const;
119  const char *getDynamicTagAsString(uint64_t Type) const;
120 
121  /// Get the symbol for a given relocation.
123  const Elf_Shdr *SymTab) const;
124 
125  static Expected<ELFFile> create(StringRef Object);
126 
127  bool isMipsELF64() const {
128  return getHeader()->e_machine == ELF::EM_MIPS &&
129  getHeader()->getFileClass() == ELF::ELFCLASS64;
130  }
131 
132  bool isMips64EL() const {
133  return isMipsELF64() &&
134  getHeader()->getDataEncoding() == ELF::ELFDATA2LSB;
135  }
136 
138 
140 
141  Expected<const uint8_t *> toMappedAddr(uint64_t VAddr) const;
142 
144  if (!Sec)
145  return makeArrayRef<Elf_Sym>(nullptr, nullptr);
146  return getSectionContentsAsArray<Elf_Sym>(Sec);
147  }
148 
150  return getSectionContentsAsArray<Elf_Rela>(Sec);
151  }
152 
154  return getSectionContentsAsArray<Elf_Rel>(Sec);
155  }
156 
158  return getSectionContentsAsArray<Elf_Relr>(Sec);
159  }
160 
162 
164 
165  /// Iterate over program header table.
167  if (getHeader()->e_phnum && getHeader()->e_phentsize != sizeof(Elf_Phdr))
168  return createError("invalid e_phentsize");
169  if (getHeader()->e_phoff +
170  (getHeader()->e_phnum * getHeader()->e_phentsize) >
171  getBufSize())
172  return createError("program headers longer than binary");
173  auto *Begin =
174  reinterpret_cast<const Elf_Phdr *>(base() + getHeader()->e_phoff);
175  return makeArrayRef(Begin, Begin + getHeader()->e_phnum);
176  }
177 
178  /// Get an iterator over notes in a program header.
179  ///
180  /// The program header must be of type \c PT_NOTE.
181  ///
182  /// \param Phdr the program header to iterate over.
183  /// \param Err [out] an error to support fallible iteration, which should
184  /// be checked after iteration ends.
185  Elf_Note_Iterator notes_begin(const Elf_Phdr &Phdr, Error &Err) const {
186  if (Phdr.p_type != ELF::PT_NOTE) {
187  Err = createError("attempt to iterate notes of non-note program header");
188  return Elf_Note_Iterator(Err);
189  }
190  if (Phdr.p_offset + Phdr.p_filesz > getBufSize()) {
191  Err = createError("invalid program header offset/size");
192  return Elf_Note_Iterator(Err);
193  }
194  return Elf_Note_Iterator(base() + Phdr.p_offset, Phdr.p_filesz, Err);
195  }
196 
197  /// Get an iterator over notes in a section.
198  ///
199  /// The section must be of type \c SHT_NOTE.
200  ///
201  /// \param Shdr the section to iterate over.
202  /// \param Err [out] an error to support fallible iteration, which should
203  /// be checked after iteration ends.
204  Elf_Note_Iterator notes_begin(const Elf_Shdr &Shdr, Error &Err) const {
205  if (Shdr.sh_type != ELF::SHT_NOTE) {
206  Err = createError("attempt to iterate notes of non-note section");
207  return Elf_Note_Iterator(Err);
208  }
209  if (Shdr.sh_offset + Shdr.sh_size > getBufSize()) {
210  Err = createError("invalid section offset/size");
211  return Elf_Note_Iterator(Err);
212  }
213  return Elf_Note_Iterator(base() + Shdr.sh_offset, Shdr.sh_size, Err);
214  }
215 
216  /// Get the end iterator for notes.
218  return Elf_Note_Iterator();
219  }
220 
221  /// Get an iterator range over notes of a program header.
222  ///
223  /// The program header must be of type \c PT_NOTE.
224  ///
225  /// \param Phdr the program header to iterate over.
226  /// \param Err [out] an error to support fallible iteration, which should
227  /// be checked after iteration ends.
229  Error &Err) const {
230  return make_range(notes_begin(Phdr, Err), notes_end());
231  }
232 
233  /// Get an iterator range over notes of a section.
234  ///
235  /// The section must be of type \c SHT_NOTE.
236  ///
237  /// \param Shdr the section to iterate over.
238  /// \param Err [out] an error to support fallible iteration, which should
239  /// be checked after iteration ends.
241  Error &Err) const {
242  return make_range(notes_begin(Shdr, Err), notes_end());
243  }
244 
247  ArrayRef<Elf_Word> ShndxTable) const;
249  const Elf_Shdr *SymTab,
250  ArrayRef<Elf_Word> ShndxTable) const;
252  Elf_Sym_Range Symtab,
253  ArrayRef<Elf_Word> ShndxTable) const;
256 
258  uint32_t Index) const;
259 
260  Expected<StringRef> getSectionName(const Elf_Shdr *Section) const;
262  StringRef DotShstrtab) const;
263  template <typename T>
266 };
267 
272 
273 template <class ELFT>
275 getSection(typename ELFT::ShdrRange Sections, uint32_t Index) {
276  if (Index >= Sections.size())
277  return createError("invalid section index");
278  return &Sections[Index];
279 }
280 
281 template <class ELFT>
282 inline Expected<uint32_t>
283 getExtendedSymbolTableIndex(const typename ELFT::Sym *Sym,
284  const typename ELFT::Sym *FirstSym,
285  ArrayRef<typename ELFT::Word> ShndxTable) {
286  assert(Sym->st_shndx == ELF::SHN_XINDEX);
287  unsigned Index = Sym - FirstSym;
288  if (Index >= ShndxTable.size())
289  return createError("index past the end of the symbol table");
290 
291  // The size of the table was checked in getSHNDXTable.
292  return ShndxTable[Index];
293 }
294 
295 template <class ELFT>
298  ArrayRef<Elf_Word> ShndxTable) const {
299  uint32_t Index = Sym->st_shndx;
300  if (Index == ELF::SHN_XINDEX) {
301  auto ErrorOrIndex = getExtendedSymbolTableIndex<ELFT>(
302  Sym, Syms.begin(), ShndxTable);
303  if (!ErrorOrIndex)
304  return ErrorOrIndex.takeError();
305  return *ErrorOrIndex;
306  }
307  if (Index == ELF::SHN_UNDEF || Index >= ELF::SHN_LORESERVE)
308  return 0;
309  return Index;
310 }
311 
312 template <class ELFT>
314 ELFFile<ELFT>::getSection(const Elf_Sym *Sym, const Elf_Shdr *SymTab,
315  ArrayRef<Elf_Word> ShndxTable) const {
316  auto SymsOrErr = symbols(SymTab);
317  if (!SymsOrErr)
318  return SymsOrErr.takeError();
319  return getSection(Sym, *SymsOrErr, ShndxTable);
320 }
321 
322 template <class ELFT>
325  ArrayRef<Elf_Word> ShndxTable) const {
326  auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
327  if (!IndexOrErr)
328  return IndexOrErr.takeError();
329  uint32_t Index = *IndexOrErr;
330  if (Index == 0)
331  return nullptr;
332  return getSection(Index);
333 }
334 
335 template <class ELFT>
337 getSymbol(typename ELFT::SymRange Symbols, uint32_t Index) {
338  if (Index >= Symbols.size())
339  return createError("invalid symbol index");
340  return &Symbols[Index];
341 }
342 
343 template <class ELFT>
346  auto SymtabOrErr = symbols(Sec);
347  if (!SymtabOrErr)
348  return SymtabOrErr.takeError();
349  return object::getSymbol<ELFT>(*SymtabOrErr, Index);
350 }
351 
352 template <class ELFT>
353 template <typename T>
356  if (Sec->sh_entsize != sizeof(T) && sizeof(T) != 1)
357  return createError("invalid sh_entsize");
358 
359  uintX_t Offset = Sec->sh_offset;
360  uintX_t Size = Sec->sh_size;
361 
362  if (Size % sizeof(T))
363  return createError("size is not a multiple of sh_entsize");
364  if ((std::numeric_limits<uintX_t>::max() - Offset < Size) ||
365  Offset + Size > Buf.size())
366  return createError("invalid section offset");
367 
368  if (Offset % alignof(T))
369  return createError("unaligned data");
370 
371  const T *Start = reinterpret_cast<const T *>(base() + Offset);
372  return makeArrayRef(Start, Size / sizeof(T));
373 }
374 
375 template <class ELFT>
378  return getSectionContentsAsArray<uint8_t>(Sec);
379 }
380 
381 template <class ELFT>
383  return getELFRelocationTypeName(getHeader()->e_machine, Type);
384 }
385 
386 template <class ELFT>
388  SmallVectorImpl<char> &Result) const {
389  if (!isMipsELF64()) {
391  Result.append(Name.begin(), Name.end());
392  } else {
393  // The Mips N64 ABI allows up to three operations to be specified per
394  // relocation record. Unfortunately there's no easy way to test for the
395  // presence of N64 ELFs as they have no special flag that identifies them
396  // as being N64. We can safely assume at the moment that all Mips
397  // ELFCLASS64 ELFs are N64. New Mips64 ABIs should provide enough
398  // information to disambiguate between old vs new ABIs.
399  uint8_t Type1 = (Type >> 0) & 0xFF;
400  uint8_t Type2 = (Type >> 8) & 0xFF;
401  uint8_t Type3 = (Type >> 16) & 0xFF;
402 
403  // Concat all three relocation type names.
405  Result.append(Name.begin(), Name.end());
406 
407  Name = getRelocationTypeName(Type2);
408  Result.append(1, '/');
409  Result.append(Name.begin(), Name.end());
410 
411  Name = getRelocationTypeName(Type3);
412  Result.append(1, '/');
413  Result.append(Name.begin(), Name.end());
414  }
415 }
416 
417 template <class ELFT>
419  return getELFRelrRelocationType(getHeader()->e_machine);
420 }
421 
422 template <class ELFT>
425  const Elf_Shdr *SymTab) const {
426  uint32_t Index = Rel->getSymbol(isMips64EL());
427  if (Index == 0)
428  return nullptr;
429  return getEntry<Elf_Sym>(SymTab, Index);
430 }
431 
432 template <class ELFT>
435  uint32_t Index = getHeader()->e_shstrndx;
436  if (Index == ELF::SHN_XINDEX)
437  Index = Sections[0].sh_link;
438 
439  if (!Index) // no section string table.
440  return "";
441  if (Index >= Sections.size())
442  return createError("invalid section index");
443  return getStringTable(&Sections[Index]);
444 }
445 
446 template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {}
447 
448 template <class ELFT>
450  if (sizeof(Elf_Ehdr) > Object.size())
451  return createError("Invalid buffer");
452  return ELFFile(Object);
453 }
454 
455 template <class ELFT>
457  const uintX_t SectionTableOffset = getHeader()->e_shoff;
458  if (SectionTableOffset == 0)
459  return ArrayRef<Elf_Shdr>();
460 
461  if (getHeader()->e_shentsize != sizeof(Elf_Shdr))
462  return createError(
463  "invalid section header entry size (e_shentsize) in ELF header");
464 
465  const uint64_t FileSize = Buf.size();
466 
467  if (SectionTableOffset + sizeof(Elf_Shdr) > FileSize)
468  return createError("section header table goes past the end of the file");
469 
470  // Invalid address alignment of section headers
471  if (SectionTableOffset & (alignof(Elf_Shdr) - 1))
472  return createError("invalid alignment of section headers");
473 
474  const Elf_Shdr *First =
475  reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
476 
477  uintX_t NumSections = getHeader()->e_shnum;
478  if (NumSections == 0)
479  NumSections = First->sh_size;
480 
481  if (NumSections > UINT64_MAX / sizeof(Elf_Shdr))
482  return createError("section table goes past the end of file");
483 
484  const uint64_t SectionTableSize = NumSections * sizeof(Elf_Shdr);
485 
486  // Section table goes past end of file!
487  if (SectionTableOffset + SectionTableSize > FileSize)
488  return createError("section table goes past the end of file");
489 
490  return makeArrayRef(First, NumSections);
491 }
492 
493 template <class ELFT>
494 template <typename T>
496  uint32_t Entry) const {
497  auto SecOrErr = getSection(Section);
498  if (!SecOrErr)
499  return SecOrErr.takeError();
500  return getEntry<T>(*SecOrErr, Entry);
501 }
502 
503 template <class ELFT>
504 template <typename T>
506  uint32_t Entry) const {
507  if (sizeof(T) != Section->sh_entsize)
508  return createError("invalid sh_entsize");
509  size_t Pos = Section->sh_offset + Entry * sizeof(T);
510  if (Pos + sizeof(T) > Buf.size())
511  return createError("invalid section offset");
512  return reinterpret_cast<const T *>(base() + Pos);
513 }
514 
515 template <class ELFT>
518  auto TableOrErr = sections();
519  if (!TableOrErr)
520  return TableOrErr.takeError();
521  return object::getSection<ELFT>(*TableOrErr, Index);
522 }
523 
524 template <class ELFT>
527  auto TableOrErr = sections();
528  if (!TableOrErr)
529  return TableOrErr.takeError();
530  for (auto &Sec : *TableOrErr) {
531  auto SecNameOrErr = getSectionName(&Sec);
532  if (!SecNameOrErr)
533  return SecNameOrErr.takeError();
534  if (*SecNameOrErr == SectionName)
535  return &Sec;
536  }
537  return createError("invalid section name");
538 }
539 
540 template <class ELFT>
543  if (Section->sh_type != ELF::SHT_STRTAB)
544  return createError("invalid sh_type for string table, expected SHT_STRTAB");
545  auto V = getSectionContentsAsArray<char>(Section);
546  if (!V)
547  return V.takeError();
548  ArrayRef<char> Data = *V;
549  if (Data.empty())
550  return createError("empty string table");
551  if (Data.back() != '\0')
552  return createError("string table non-null terminated");
553  return StringRef(Data.begin(), Data.size());
554 }
555 
556 template <class ELFT>
559  auto SectionsOrErr = sections();
560  if (!SectionsOrErr)
561  return SectionsOrErr.takeError();
562  return getSHNDXTable(Section, *SectionsOrErr);
563 }
564 
565 template <class ELFT>
568  Elf_Shdr_Range Sections) const {
569  assert(Section.sh_type == ELF::SHT_SYMTAB_SHNDX);
570  auto VOrErr = getSectionContentsAsArray<Elf_Word>(&Section);
571  if (!VOrErr)
572  return VOrErr.takeError();
573  ArrayRef<Elf_Word> V = *VOrErr;
574  auto SymTableOrErr = object::getSection<ELFT>(Sections, Section.sh_link);
575  if (!SymTableOrErr)
576  return SymTableOrErr.takeError();
577  const Elf_Shdr &SymTable = **SymTableOrErr;
578  if (SymTable.sh_type != ELF::SHT_SYMTAB &&
579  SymTable.sh_type != ELF::SHT_DYNSYM)
580  return createError("invalid sh_type");
581  if (V.size() != (SymTable.sh_size / sizeof(Elf_Sym)))
582  return createError("invalid section contents size");
583  return V;
584 }
585 
586 template <class ELFT>
589  auto SectionsOrErr = sections();
590  if (!SectionsOrErr)
591  return SectionsOrErr.takeError();
592  return getStringTableForSymtab(Sec, *SectionsOrErr);
593 }
594 
595 template <class ELFT>
598  Elf_Shdr_Range Sections) const {
599 
600  if (Sec.sh_type != ELF::SHT_SYMTAB && Sec.sh_type != ELF::SHT_DYNSYM)
601  return createError(
602  "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
603  auto SectionOrErr = object::getSection<ELFT>(Sections, Sec.sh_link);
604  if (!SectionOrErr)
605  return SectionOrErr.takeError();
606  return getStringTable(*SectionOrErr);
607 }
608 
609 template <class ELFT>
612  auto SectionsOrErr = sections();
613  if (!SectionsOrErr)
614  return SectionsOrErr.takeError();
615  auto Table = getSectionStringTable(*SectionsOrErr);
616  if (!Table)
617  return Table.takeError();
618  return getSectionName(Section, *Table);
619 }
620 
621 template <class ELFT>
623  StringRef DotShstrtab) const {
624  uint32_t Offset = Section->sh_name;
625  if (Offset == 0)
626  return StringRef();
627  if (Offset >= DotShstrtab.size())
628  return createError("invalid string offset");
629  return StringRef(DotShstrtab.data() + Offset);
630 }
631 
632 /// This function returns the hash value for a symbol in the .dynsym section
633 /// Name of the API remains consistent as specified in the libelf
634 /// REF : http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#hash
635 inline unsigned hashSysV(StringRef SymbolName) {
636  unsigned h = 0, g;
637  for (char C : SymbolName) {
638  h = (h << 4) + C;
639  g = h & 0xf0000000L;
640  if (g != 0)
641  h ^= g >> 24;
642  h &= ~g;
643  }
644  return h;
645 }
646 
647 } // end namespace object
648 } // end namespace llvm
649 
650 #endif // LLVM_OBJECT_ELF_H
typename ELFT::Dyn Elf_Dyn
Definition: ELF.h:60
uint64_t CallInst * C
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
const T & back() const
back - Get the last element.
Definition: ArrayRef.h:158
typename ELFT::Rel Elf_Rel
Definition: ELF.h:62
iterator_range< Elf_Note_Iterator > notes(const Elf_Phdr &Phdr, Error &Err) const
Get an iterator range over notes of a program header.
Definition: ELF.h:228
Expected< const T * > getEntry(uint32_t Section, uint32_t Entry) const
Definition: ELF.h:495
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
typename ELFT::Note Elf_Note
Definition: ELF.h:73
static Expected< ELFFile > create(StringRef Object)
Definition: ELF.h:449
iterator begin() const
Definition: ArrayRef.h:137
typename ELFT::Vernaux Elf_Vernaux
Definition: ELF.h:68
StringRef getELFSectionTypeName(uint32_t Machine, uint32_t Type)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Definition: StringRef.h:138
StringRef getRelocationTypeName(uint32_t Type) const
Definition: ELF.h:382
uint32_t getELFRelrRelocationType(uint32_t Machine)
Definition: ELF.cpp:150
Expected< StringRef > getSectionStringTable(Elf_Shdr_Range Sections) const
Definition: ELF.h:434
const char * getDynamicTagAsString(unsigned Arch, uint64_t Type) const
Definition: ELF.cpp:421
ELFYAML::ELF_REL Type3
Definition: ELFYAML.cpp:938
Expected< StringRef > getStringTable(const Elf_Shdr *Section) const
Definition: ELF.h:542
static Error createError(StringRef Err)
Definition: ELF.h:48
Expected< std::vector< Elf_Rela > > decode_relrs(Elf_Relr_Range relrs) const
Definition: ELF.cpp:262
unsigned hashSysV(StringRef SymbolName)
This function returns the hash value for a symbol in the .dynsym section Name of the API remains cons...
Definition: ELF.h:635
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:128
typename ELFT::Sym Elf_Sym
Definition: ELF.h:59
Expected< Elf_Phdr_Range > program_headers() const
Iterate over program header table.
Definition: ELF.h:166
uint32_t getRelrRelocationType() const
Definition: ELF.h:418
Expected< const uint8_t * > toMappedAddr(uint64_t VAddr) const
Definition: ELF.cpp:531
const uint8_t * base() const
Definition: ELF.h:83
Expected< const Elf_Shdr * > getSection(const Elf_Sym *Sym, const Elf_Shdr *SymTab, ArrayRef< Elf_Word > ShndxTable) const
Definition: ELF.h:314
amdgpu Simplify well known AMD library false Value Value const Twine & Name
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
bool isMips64EL() const
Definition: ELF.h:132
iterator_range< Elf_Note_Iterator > notes(const Elf_Shdr &Shdr, Error &Err) const
Get an iterator range over notes of a section.
Definition: ELF.h:240
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:451
Expected< Elf_Shdr_Range > sections() const
Definition: ELF.h:456
typename ELFT::PhdrRange Elf_Phdr_Range
Definition: ELF.h:81
typename ELFT::Phdr Elf_Phdr
Definition: ELF.h:61
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
Expected< ArrayRef< uint8_t > > getSectionContents(const Elf_Shdr *Sec) const
Definition: ELF.h:377
#define UINT64_MAX
Definition: DataTypes.h:83
#define T
typename ELFT::Relr Elf_Relr
Definition: ELF.h:64
std::pair< unsigned char, unsigned char > getElfArchType(StringRef Object)
Definition: ELF.h:40
typename ELFT::GnuHash Elf_GnuHash
Definition: ELF.h:71
COFF::MachineTypes Machine
Definition: COFFYAML.cpp:363
typename ELFT::SymRange Elf_Sym_Range
Definition: ELF.h:77
Elf_Note_Iterator notes_end() const
Get the end iterator for notes.
Definition: ELF.h:217
Expected< ArrayRef< T > > getSectionContentsAsArray(const Elf_Shdr *Sec) const
Definition: ELF.h:355
Expected< Elf_Rel_Range > rels(const Elf_Shdr *Sec) const
Definition: ELF.h:153
Expected< ArrayRef< Elf_Word > > getSHNDXTable(const Elf_Shdr &Section) const
Definition: ELF.h:558
bool isMipsELF64() const
Definition: ELF.h:127
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
Elf_Note_Iterator notes_begin(const Elf_Shdr &Shdr, Error &Err) const
Get an iterator over notes in a section.
Definition: ELF.h:204
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
Expected< StringRef > getStringTableForSymtab(const Elf_Shdr &Section) const
Definition: ELF.h:588
Expected< Elf_Rela_Range > relas(const Elf_Shdr *Sec) const
Definition: ELF.h:149
typename ELFT::uint uintX_t
Definition: ELF.h:56
Expected< uint32_t > getSectionIndex(const Elf_Sym *Sym, Elf_Sym_Range Syms, ArrayRef< Elf_Word > ShndxTable) const
Definition: ELF.h:297
Expected< Elf_Relr_Range > relrs(const Elf_Shdr *Sec) const
Definition: ELF.h:157
typename ELFT::NoteIterator Elf_Note_Iterator
Definition: ELF.h:74
typename ELFT::Nhdr Elf_Nhdr
Definition: ELF.h:72
typename ELFT::Verdaux Elf_Verdaux
Definition: ELF.h:66
typename ELFT::Ehdr Elf_Ehdr
Definition: ELF.h:57
typename ELFT::RelrRange Elf_Relr_Range
Definition: ELF.h:80
typename ELFT::Rela Elf_Rela
Definition: ELF.h:63
typename ELFT::Verneed Elf_Verneed
Definition: ELF.h:67
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type)
Definition: ELF.cpp:23
Expected< uint32_t > getExtendedSymbolTableIndex(const typename ELFT::Sym *Sym, const typename ELFT::Sym *FirstSym, ArrayRef< typename ELFT::Word > ShndxTable)
Definition: ELF.h:283
size_t getBufSize() const
Definition: ELF.h:87
Expected< const Elf_Sym * > getRelocationSymbol(const Elf_Rel *Rel, const Elf_Shdr *SymTab) const
Get the symbol for a given relocation.
Definition: ELF.h:424
A range adaptor for a pair of iterators.
iterator begin() const
Definition: StringRef.h:106
Elf_Note_Iterator notes_begin(const Elf_Phdr &Phdr, Error &Err) const
Get an iterator over notes in a program header.
Definition: ELF.h:185
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:394
typename ELFT::DynRange Elf_Dyn_Range
Definition: ELF.h:75
ELFYAML::ELF_REL Type2
Definition: ELFYAML.cpp:937
Expected< std::vector< Elf_Rela > > android_relas(const Elf_Shdr *Sec) const
Definition: ELF.cpp:341
Expected< const Elf_Sym * > getSymbol(const Elf_Shdr *Sec, uint32_t Index) const
Definition: ELF.h:345
Expected< Elf_Sym_Range > symbols(const Elf_Shdr *Sec) const
Definition: ELF.h:143
uint32_t Size
Definition: Profile.cpp:47
typename ELFT::Verdef Elf_Verdef
Definition: ELF.h:65
Expected< Elf_Dyn_Range > dynamicEntries() const
Definition: ELF.cpp:477
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
typename ELFT::RelRange Elf_Rel_Range
Definition: ELF.h:78
aarch64 promote const
typename ELFT::Versym Elf_Versym
Definition: ELF.h:69
typename ELFT::RelaRange Elf_Rela_Range
Definition: ELF.h:79
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
#define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
Definition: ELFTypes.h:104
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
typename ELFT::ShdrRange Elf_Shdr_Range
Definition: ELF.h:76
const Elf_Ehdr * getHeader() const
Definition: ELF.h:95
iterator end() const
Definition: StringRef.h:108
typename ELFT::Shdr Elf_Shdr
Definition: ELF.h:58
Expected< StringRef > getSectionName(const Elf_Shdr *Section) const
Definition: ELF.h:611
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:144
typename ELFT::Hash Elf_Hash
Definition: ELF.h:70