LLVM  15.0.0git
ELFTypes.h
Go to the documentation of this file.
1 //===- ELFTypes.h - Endian specific types for ELF ---------------*- 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 #ifndef LLVM_OBJECT_ELFTYPES_H
10 #define LLVM_OBJECT_ELFTYPES_H
11 
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/BinaryFormat/ELF.h"
15 #include "llvm/Object/Error.h"
16 #include "llvm/Support/Endian.h"
17 #include "llvm/Support/Error.h"
19 #include <cassert>
20 #include <cstdint>
21 #include <cstring>
22 #include <type_traits>
23 
24 namespace llvm {
25 namespace object {
26 
28 
29 template <class ELFT> struct Elf_Ehdr_Impl;
30 template <class ELFT> struct Elf_Shdr_Impl;
31 template <class ELFT> struct Elf_Sym_Impl;
32 template <class ELFT> struct Elf_Dyn_Impl;
33 template <class ELFT> struct Elf_Phdr_Impl;
34 template <class ELFT, bool isRela> struct Elf_Rel_Impl;
35 template <class ELFT> struct Elf_Verdef_Impl;
36 template <class ELFT> struct Elf_Verdaux_Impl;
37 template <class ELFT> struct Elf_Verneed_Impl;
38 template <class ELFT> struct Elf_Vernaux_Impl;
39 template <class ELFT> struct Elf_Versym_Impl;
40 template <class ELFT> struct Elf_Hash_Impl;
41 template <class ELFT> struct Elf_GnuHash_Impl;
42 template <class ELFT> struct Elf_Chdr_Impl;
43 template <class ELFT> struct Elf_Nhdr_Impl;
44 template <class ELFT> class Elf_Note_Impl;
45 template <class ELFT> class Elf_Note_Iterator_Impl;
46 template <class ELFT> struct Elf_CGProfile_Impl;
47 
48 template <endianness E, bool Is64> struct ELFType {
49 private:
50  template <typename Ty>
52 
53 public:
54  static const endianness TargetEndianness = E;
55  static const bool Is64Bits = Is64;
56 
57  using uint = std::conditional_t<Is64, uint64_t, uint32_t>;
65  using Relr = packed<uint>;
85 
91  using Addr = packed<uint>;
92  using Off = packed<uint>;
93 };
94 
99 
100 // Use an alignment of 2 for the typedefs since that is the worst case for
101 // ELF files in archives.
102 
103 // I really don't like doing this, but the alternative is copypasta.
104 #define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) \
105  using Elf_Addr = typename ELFT::Addr; \
106  using Elf_Off = typename ELFT::Off; \
107  using Elf_Half = typename ELFT::Half; \
108  using Elf_Word = typename ELFT::Word; \
109  using Elf_Sword = typename ELFT::Sword; \
110  using Elf_Xword = typename ELFT::Xword; \
111  using Elf_Sxword = typename ELFT::Sxword; \
112  using uintX_t = typename ELFT::uint; \
113  using Elf_Ehdr = typename ELFT::Ehdr; \
114  using Elf_Shdr = typename ELFT::Shdr; \
115  using Elf_Sym = typename ELFT::Sym; \
116  using Elf_Dyn = typename ELFT::Dyn; \
117  using Elf_Phdr = typename ELFT::Phdr; \
118  using Elf_Rel = typename ELFT::Rel; \
119  using Elf_Rela = typename ELFT::Rela; \
120  using Elf_Relr = typename ELFT::Relr; \
121  using Elf_Verdef = typename ELFT::Verdef; \
122  using Elf_Verdaux = typename ELFT::Verdaux; \
123  using Elf_Verneed = typename ELFT::Verneed; \
124  using Elf_Vernaux = typename ELFT::Vernaux; \
125  using Elf_Versym = typename ELFT::Versym; \
126  using Elf_Hash = typename ELFT::Hash; \
127  using Elf_GnuHash = typename ELFT::GnuHash; \
128  using Elf_Nhdr = typename ELFT::Nhdr; \
129  using Elf_Note = typename ELFT::Note; \
130  using Elf_Note_Iterator = typename ELFT::NoteIterator; \
131  using Elf_CGProfile = typename ELFT::CGProfile; \
132  using Elf_Dyn_Range = typename ELFT::DynRange; \
133  using Elf_Shdr_Range = typename ELFT::ShdrRange; \
134  using Elf_Sym_Range = typename ELFT::SymRange; \
135  using Elf_Rel_Range = typename ELFT::RelRange; \
136  using Elf_Rela_Range = typename ELFT::RelaRange; \
137  using Elf_Relr_Range = typename ELFT::RelrRange; \
138  using Elf_Phdr_Range = typename ELFT::PhdrRange;
139 
140 #define LLVM_ELF_COMMA ,
141 #define LLVM_ELF_IMPORT_TYPES(E, W) \
142  LLVM_ELF_IMPORT_TYPES_ELFT(ELFType<E LLVM_ELF_COMMA W>)
143 
144 // Section header.
145 template <class ELFT> struct Elf_Shdr_Base;
146 
147 template <endianness TargetEndianness>
148 struct Elf_Shdr_Base<ELFType<TargetEndianness, false>> {
149  LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
150  Elf_Word sh_name; // Section name (index into string table)
151  Elf_Word sh_type; // Section type (SHT_*)
152  Elf_Word sh_flags; // Section flags (SHF_*)
153  Elf_Addr sh_addr; // Address where section is to be loaded
154  Elf_Off sh_offset; // File offset of section data, in bytes
155  Elf_Word sh_size; // Size of section, in bytes
156  Elf_Word sh_link; // Section type-specific header table index link
157  Elf_Word sh_info; // Section type-specific extra information
158  Elf_Word sh_addralign; // Section address alignment
159  Elf_Word sh_entsize; // Size of records contained within the section
160 };
161 
162 template <endianness TargetEndianness>
163 struct Elf_Shdr_Base<ELFType<TargetEndianness, true>> {
164  LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
165  Elf_Word sh_name; // Section name (index into string table)
166  Elf_Word sh_type; // Section type (SHT_*)
167  Elf_Xword sh_flags; // Section flags (SHF_*)
168  Elf_Addr sh_addr; // Address where section is to be loaded
169  Elf_Off sh_offset; // File offset of section data, in bytes
170  Elf_Xword sh_size; // Size of section, in bytes
171  Elf_Word sh_link; // Section type-specific header table index link
172  Elf_Word sh_info; // Section type-specific extra information
173  Elf_Xword sh_addralign; // Section address alignment
174  Elf_Xword sh_entsize; // Size of records contained within the section
175 };
176 
177 template <class ELFT>
178 struct Elf_Shdr_Impl : Elf_Shdr_Base<ELFT> {
181 
182  /// Get the number of entities this section contains if it has any.
183  unsigned getEntityCount() const {
184  if (sh_entsize == 0)
185  return 0;
186  return sh_size / sh_entsize;
187  }
188 };
189 
190 template <class ELFT> struct Elf_Sym_Base;
191 
192 template <endianness TargetEndianness>
193 struct Elf_Sym_Base<ELFType<TargetEndianness, false>> {
194  LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
195  Elf_Word st_name; // Symbol name (index into string table)
196  Elf_Addr st_value; // Value or address associated with the symbol
197  Elf_Word st_size; // Size of the symbol
198  unsigned char st_info; // Symbol's type and binding attributes
199  unsigned char st_other; // Must be zero; reserved
200  Elf_Half st_shndx; // Which section (header table index) it's defined in
201 };
202 
203 template <endianness TargetEndianness>
204 struct Elf_Sym_Base<ELFType<TargetEndianness, true>> {
205  LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
206  Elf_Word st_name; // Symbol name (index into string table)
207  unsigned char st_info; // Symbol's type and binding attributes
208  unsigned char st_other; // Must be zero; reserved
209  Elf_Half st_shndx; // Which section (header table index) it's defined in
210  Elf_Addr st_value; // Value or address associated with the symbol
211  Elf_Xword st_size; // Size of the symbol
212 };
213 
214 template <class ELFT>
215 struct Elf_Sym_Impl : Elf_Sym_Base<ELFT> {
220 
221  // These accessors and mutators correspond to the ELF32_ST_BIND,
222  // ELF32_ST_TYPE, and ELF32_ST_INFO macros defined in the ELF specification:
223  unsigned char getBinding() const { return st_info >> 4; }
224  unsigned char getType() const { return st_info & 0x0f; }
225  uint64_t getValue() const { return st_value; }
226  void setBinding(unsigned char b) { setBindingAndType(b, getType()); }
227  void setType(unsigned char t) { setBindingAndType(getBinding(), t); }
228 
229  void setBindingAndType(unsigned char b, unsigned char t) {
230  st_info = (b << 4) + (t & 0x0f);
231  }
232 
233  /// Access to the STV_xxx flag stored in the first two bits of st_other.
234  /// STV_DEFAULT: 0
235  /// STV_INTERNAL: 1
236  /// STV_HIDDEN: 2
237  /// STV_PROTECTED: 3
238  unsigned char getVisibility() const { return st_other & 0x3; }
239  void setVisibility(unsigned char v) {
240  assert(v < 4 && "Invalid value for visibility");
241  st_other = (st_other & ~0x3) | v;
242  }
243 
244  bool isAbsolute() const { return st_shndx == ELF::SHN_ABS; }
245 
246  bool isCommon() const {
247  return getType() == ELF::STT_COMMON || st_shndx == ELF::SHN_COMMON;
248  }
249 
250  bool isDefined() const { return !isUndefined(); }
251 
252  bool isProcessorSpecific() const {
253  return st_shndx >= ELF::SHN_LOPROC && st_shndx <= ELF::SHN_HIPROC;
254  }
255 
256  bool isOSSpecific() const {
257  return st_shndx >= ELF::SHN_LOOS && st_shndx <= ELF::SHN_HIOS;
258  }
259 
260  bool isReserved() const {
261  // ELF::SHN_HIRESERVE is 0xffff so st_shndx <= ELF::SHN_HIRESERVE is always
262  // true and some compilers warn about it.
263  return st_shndx >= ELF::SHN_LORESERVE;
264  }
265 
266  bool isUndefined() const { return st_shndx == ELF::SHN_UNDEF; }
267 
268  bool isExternal() const {
269  return getBinding() != ELF::STB_LOCAL;
270  }
271 
272  Expected<StringRef> getName(StringRef StrTab) const;
273 };
274 
275 template <class ELFT>
277  uint32_t Offset = this->st_name;
278  if (Offset >= StrTab.size())
280  "st_name (0x%" PRIx32
281  ") is past the end of the string table"
282  " of size 0x%zx",
283  Offset, StrTab.size());
284  return StringRef(StrTab.data() + Offset);
285 }
286 
287 /// Elf_Versym: This is the structure of entries in the SHT_GNU_versym section
288 /// (.gnu.version). This structure is identical for ELF32 and ELF64.
289 template <class ELFT>
290 struct Elf_Versym_Impl {
292  Elf_Half vs_index; // Version index with flags (e.g. VERSYM_HIDDEN)
293 };
294 
295 /// Elf_Verdef: This is the structure of entries in the SHT_GNU_verdef section
296 /// (.gnu.version_d). This structure is identical for ELF32 and ELF64.
297 template <class ELFT>
298 struct Elf_Verdef_Impl {
300  Elf_Half vd_version; // Version of this structure (e.g. VER_DEF_CURRENT)
301  Elf_Half vd_flags; // Bitwise flags (VER_DEF_*)
302  Elf_Half vd_ndx; // Version index, used in .gnu.version entries
303  Elf_Half vd_cnt; // Number of Verdaux entries
304  Elf_Word vd_hash; // Hash of name
305  Elf_Word vd_aux; // Offset to the first Verdaux entry (in bytes)
306  Elf_Word vd_next; // Offset to the next Verdef entry (in bytes)
307 
308  /// Get the first Verdaux entry for this Verdef.
309  const Elf_Verdaux *getAux() const {
310  return reinterpret_cast<const Elf_Verdaux *>((const char *)this + vd_aux);
311  }
312 };
313 
314 /// Elf_Verdaux: This is the structure of auxiliary data in the SHT_GNU_verdef
315 /// section (.gnu.version_d). This structure is identical for ELF32 and ELF64.
316 template <class ELFT>
317 struct Elf_Verdaux_Impl {
319  Elf_Word vda_name; // Version name (offset in string table)
320  Elf_Word vda_next; // Offset to next Verdaux entry (in bytes)
321 };
322 
323 /// Elf_Verneed: This is the structure of entries in the SHT_GNU_verneed
324 /// section (.gnu.version_r). This structure is identical for ELF32 and ELF64.
325 template <class ELFT>
326 struct Elf_Verneed_Impl {
328  Elf_Half vn_version; // Version of this structure (e.g. VER_NEED_CURRENT)
329  Elf_Half vn_cnt; // Number of associated Vernaux entries
330  Elf_Word vn_file; // Library name (string table offset)
331  Elf_Word vn_aux; // Offset to first Vernaux entry (in bytes)
332  Elf_Word vn_next; // Offset to next Verneed entry (in bytes)
333 };
334 
335 /// Elf_Vernaux: This is the structure of auxiliary data in SHT_GNU_verneed
336 /// section (.gnu.version_r). This structure is identical for ELF32 and ELF64.
337 template <class ELFT>
338 struct Elf_Vernaux_Impl {
340  Elf_Word vna_hash; // Hash of dependency name
341  Elf_Half vna_flags; // Bitwise Flags (VER_FLAG_*)
342  Elf_Half vna_other; // Version index, used in .gnu.version entries
343  Elf_Word vna_name; // Dependency name
344  Elf_Word vna_next; // Offset to next Vernaux entry (in bytes)
345 };
346 
347 /// Elf_Dyn_Base: This structure matches the form of entries in the dynamic
348 /// table section (.dynamic) look like.
349 template <class ELFT> struct Elf_Dyn_Base;
350 
351 template <endianness TargetEndianness>
352 struct Elf_Dyn_Base<ELFType<TargetEndianness, false>> {
353  LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
354  Elf_Sword d_tag;
355  union {
356  Elf_Word d_val;
357  Elf_Addr d_ptr;
358  } d_un;
359 };
360 
361 template <endianness TargetEndianness>
362 struct Elf_Dyn_Base<ELFType<TargetEndianness, true>> {
363  LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
364  Elf_Sxword d_tag;
365  union {
366  Elf_Xword d_val;
367  Elf_Addr d_ptr;
368  } d_un;
369 };
370 
371 /// Elf_Dyn_Impl: This inherits from Elf_Dyn_Base, adding getters.
372 template <class ELFT>
373 struct Elf_Dyn_Impl : Elf_Dyn_Base<ELFT> {
374  using Elf_Dyn_Base<ELFT>::d_tag;
375  using Elf_Dyn_Base<ELFT>::d_un;
376  using intX_t = std::conditional_t<ELFT::Is64Bits, int64_t, int32_t>;
377  using uintX_t = std::conditional_t<ELFT::Is64Bits, uint64_t, uint32_t>;
378  intX_t getTag() const { return d_tag; }
379  uintX_t getVal() const { return d_un.d_val; }
380  uintX_t getPtr() const { return d_un.d_ptr; }
381 };
382 
383 template <endianness TargetEndianness>
384 struct Elf_Rel_Impl<ELFType<TargetEndianness, false>, false> {
385  LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
386  static const bool IsRela = false;
387  Elf_Addr r_offset; // Location (file byte offset, or program virtual addr)
388  Elf_Word r_info; // Symbol table index and type of relocation to apply
389 
390  uint32_t getRInfo(bool isMips64EL) const {
391  assert(!isMips64EL);
392  return r_info;
393  }
394  void setRInfo(uint32_t R, bool IsMips64EL) {
395  assert(!IsMips64EL);
396  r_info = R;
397  }
398 
399  // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
400  // and ELF32_R_INFO macros defined in the ELF specification:
402  return this->getRInfo(isMips64EL) >> 8;
403  }
404  unsigned char getType(bool isMips64EL) const {
405  return (unsigned char)(this->getRInfo(isMips64EL) & 0x0ff);
406  }
407  void setSymbol(uint32_t s, bool IsMips64EL) {
408  setSymbolAndType(s, getType(IsMips64EL), IsMips64EL);
409  }
410  void setType(unsigned char t, bool IsMips64EL) {
411  setSymbolAndType(getSymbol(IsMips64EL), t, IsMips64EL);
412  }
413  void setSymbolAndType(uint32_t s, unsigned char t, bool IsMips64EL) {
414  this->setRInfo((s << 8) + t, IsMips64EL);
415  }
416 };
417 
418 template <endianness TargetEndianness>
419 struct Elf_Rel_Impl<ELFType<TargetEndianness, false>, true>
420  : public Elf_Rel_Impl<ELFType<TargetEndianness, false>, false> {
421  LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
422  static const bool IsRela = true;
423  Elf_Sword r_addend; // Compute value for relocatable field by adding this
424 };
425 
426 template <endianness TargetEndianness>
427 struct Elf_Rel_Impl<ELFType<TargetEndianness, true>, false> {
428  LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
429  static const bool IsRela = false;
430  Elf_Addr r_offset; // Location (file byte offset, or program virtual addr)
431  Elf_Xword r_info; // Symbol table index and type of relocation to apply
432 
433  uint64_t getRInfo(bool isMips64EL) const {
434  uint64_t t = r_info;
435  if (!isMips64EL)
436  return t;
437  // Mips64 little endian has a "special" encoding of r_info. Instead of one
438  // 64 bit little endian number, it is a little endian 32 bit number followed
439  // by a 32 bit big endian number.
440  return (t << 32) | ((t >> 8) & 0xff000000) | ((t >> 24) & 0x00ff0000) |
441  ((t >> 40) & 0x0000ff00) | ((t >> 56) & 0x000000ff);
442  }
443 
444  void setRInfo(uint64_t R, bool IsMips64EL) {
445  if (IsMips64EL)
446  r_info = (R >> 32) | ((R & 0xff000000) << 8) | ((R & 0x00ff0000) << 24) |
447  ((R & 0x0000ff00) << 40) | ((R & 0x000000ff) << 56);
448  else
449  r_info = R;
450  }
451 
452  // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE,
453  // and ELF64_R_INFO macros defined in the ELF specification:
455  return (uint32_t)(this->getRInfo(isMips64EL) >> 32);
456  }
458  return (uint32_t)(this->getRInfo(isMips64EL) & 0xffffffffL);
459  }
460  void setSymbol(uint32_t s, bool IsMips64EL) {
461  setSymbolAndType(s, getType(IsMips64EL), IsMips64EL);
462  }
463  void setType(uint32_t t, bool IsMips64EL) {
464  setSymbolAndType(getSymbol(IsMips64EL), t, IsMips64EL);
465  }
466  void setSymbolAndType(uint32_t s, uint32_t t, bool IsMips64EL) {
467  this->setRInfo(((uint64_t)s << 32) + (t & 0xffffffffL), IsMips64EL);
468  }
469 };
470 
471 template <endianness TargetEndianness>
472 struct Elf_Rel_Impl<ELFType<TargetEndianness, true>, true>
473  : public Elf_Rel_Impl<ELFType<TargetEndianness, true>, false> {
474  LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
475  static const bool IsRela = true;
476  Elf_Sxword r_addend; // Compute value for relocatable field by adding this.
477 };
478 
479 template <class ELFT>
480 struct Elf_Ehdr_Impl {
482  unsigned char e_ident[ELF::EI_NIDENT]; // ELF Identification bytes
483  Elf_Half e_type; // Type of file (see ET_*)
484  Elf_Half e_machine; // Required architecture for this file (see EM_*)
485  Elf_Word e_version; // Must be equal to 1
486  Elf_Addr e_entry; // Address to jump to in order to start program
487  Elf_Off e_phoff; // Program header table's file offset, in bytes
488  Elf_Off e_shoff; // Section header table's file offset, in bytes
489  Elf_Word e_flags; // Processor-specific flags
490  Elf_Half e_ehsize; // Size of ELF header, in bytes
491  Elf_Half e_phentsize; // Size of an entry in the program header table
492  Elf_Half e_phnum; // Number of entries in the program header table
493  Elf_Half e_shentsize; // Size of an entry in the section header table
494  Elf_Half e_shnum; // Number of entries in the section header table
495  Elf_Half e_shstrndx; // Section header table index of section name
496  // string table
497 
498  bool checkMagic() const {
499  return (memcmp(e_ident, ELF::ElfMagic, strlen(ELF::ElfMagic))) == 0;
500  }
501 
502  unsigned char getFileClass() const { return e_ident[ELF::EI_CLASS]; }
503  unsigned char getDataEncoding() const { return e_ident[ELF::EI_DATA]; }
504 };
505 
506 template <endianness TargetEndianness>
507 struct Elf_Phdr_Impl<ELFType<TargetEndianness, false>> {
508  LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
509  Elf_Word p_type; // Type of segment
510  Elf_Off p_offset; // FileOffset where segment is located, in bytes
511  Elf_Addr p_vaddr; // Virtual Address of beginning of segment
512  Elf_Addr p_paddr; // Physical address of beginning of segment (OS-specific)
513  Elf_Word p_filesz; // Num. of bytes in file image of segment (may be zero)
514  Elf_Word p_memsz; // Num. of bytes in mem image of segment (may be zero)
515  Elf_Word p_flags; // Segment flags
516  Elf_Word p_align; // Segment alignment constraint
517 };
518 
519 template <endianness TargetEndianness>
520 struct Elf_Phdr_Impl<ELFType<TargetEndianness, true>> {
521  LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
522  Elf_Word p_type; // Type of segment
523  Elf_Word p_flags; // Segment flags
524  Elf_Off p_offset; // FileOffset where segment is located, in bytes
525  Elf_Addr p_vaddr; // Virtual Address of beginning of segment
526  Elf_Addr p_paddr; // Physical address of beginning of segment (OS-specific)
527  Elf_Xword p_filesz; // Num. of bytes in file image of segment (may be zero)
528  Elf_Xword p_memsz; // Num. of bytes in mem image of segment (may be zero)
529  Elf_Xword p_align; // Segment alignment constraint
530 };
531 
532 // ELFT needed for endianness.
533 template <class ELFT>
534 struct Elf_Hash_Impl {
536  Elf_Word nbucket;
537  Elf_Word nchain;
538 
539  ArrayRef<Elf_Word> buckets() const {
540  return ArrayRef<Elf_Word>(&nbucket + 2, &nbucket + 2 + nbucket);
541  }
542 
544  return ArrayRef<Elf_Word>(&nbucket + 2 + nbucket,
545  &nbucket + 2 + nbucket + nchain);
546  }
547 };
548 
549 // .gnu.hash section
550 template <class ELFT>
551 struct Elf_GnuHash_Impl {
553  Elf_Word nbuckets;
554  Elf_Word symndx;
555  Elf_Word maskwords;
556  Elf_Word shift2;
557 
558  ArrayRef<Elf_Off> filter() const {
559  return ArrayRef<Elf_Off>(reinterpret_cast<const Elf_Off *>(&shift2 + 1),
560  maskwords);
561  }
562 
564  return ArrayRef<Elf_Word>(
565  reinterpret_cast<const Elf_Word *>(filter().end()), nbuckets);
566  }
567 
568  ArrayRef<Elf_Word> values(unsigned DynamicSymCount) const {
569  assert(DynamicSymCount >= symndx);
570  return ArrayRef<Elf_Word>(buckets().end(), DynamicSymCount - symndx);
571  }
572 };
573 
574 // Compressed section headers.
575 // http://www.sco.com/developers/gabi/latest/ch4.sheader.html#compression_header
576 template <endianness TargetEndianness>
577 struct Elf_Chdr_Impl<ELFType<TargetEndianness, false>> {
578  LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
579  Elf_Word ch_type;
580  Elf_Word ch_size;
581  Elf_Word ch_addralign;
582 };
583 
584 template <endianness TargetEndianness>
585 struct Elf_Chdr_Impl<ELFType<TargetEndianness, true>> {
586  LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
587  Elf_Word ch_type;
588  Elf_Word ch_reserved;
589  Elf_Xword ch_size;
590  Elf_Xword ch_addralign;
591 };
592 
593 /// Note header
594 template <class ELFT>
595 struct Elf_Nhdr_Impl {
597  Elf_Word n_namesz;
598  Elf_Word n_descsz;
599  Elf_Word n_type;
600 
601  /// The alignment of the name and descriptor.
602  ///
603  /// Implementations differ from the specification here: in practice all
604  /// variants align both the name and descriptor to 4-bytes.
605  static const unsigned int Align = 4;
606 
607  /// Get the size of the note, including name, descriptor, and padding.
608  size_t getSize() const {
609  return sizeof(*this) + alignTo<Align>(n_namesz) + alignTo<Align>(n_descsz);
610  }
611 };
612 
613 /// An ELF note.
614 ///
615 /// Wraps a note header, providing methods for accessing the name and
616 /// descriptor safely.
617 template <class ELFT>
618 class Elf_Note_Impl {
620 
621  const Elf_Nhdr_Impl<ELFT> &Nhdr;
622 
623  template <class NoteIteratorELFT> friend class Elf_Note_Iterator_Impl;
624 
625 public:
626  Elf_Note_Impl(const Elf_Nhdr_Impl<ELFT> &Nhdr) : Nhdr(Nhdr) {}
627 
628  /// Get the note's name, excluding the terminating null byte.
629  StringRef getName() const {
630  if (!Nhdr.n_namesz)
631  return StringRef();
632  return StringRef(reinterpret_cast<const char *>(&Nhdr) + sizeof(Nhdr),
633  Nhdr.n_namesz - 1);
634  }
635 
636  /// Get the note's descriptor.
638  if (!Nhdr.n_descsz)
639  return ArrayRef<uint8_t>();
640  return ArrayRef<uint8_t>(
641  reinterpret_cast<const uint8_t *>(&Nhdr) + sizeof(Nhdr) +
642  alignTo<Elf_Nhdr_Impl<ELFT>::Align>(Nhdr.n_namesz),
643  Nhdr.n_descsz);
644  }
645 
646  /// Get the note's descriptor as StringRef
648  ArrayRef<uint8_t> Desc = getDesc();
649  return StringRef(reinterpret_cast<const char *>(Desc.data()), Desc.size());
650  }
651 
652  /// Get the note's type.
653  Elf_Word getType() const { return Nhdr.n_type; }
654 };
655 
656 template <class ELFT> class Elf_Note_Iterator_Impl {
657 public:
658  using iterator_category = std::forward_iterator_tag;
660  using difference_type = std::ptrdiff_t;
661  using pointer = value_type *;
663 
664 private:
665  // Nhdr being a nullptr marks the end of iteration.
666  const Elf_Nhdr_Impl<ELFT> *Nhdr = nullptr;
667  size_t RemainingSize = 0u;
668  Error *Err = nullptr;
669 
670  template <class ELFFileELFT> friend class ELFFile;
671 
672  // Stop iteration and indicate an overflow.
673  void stopWithOverflowError() {
674  Nhdr = nullptr;
675  *Err = make_error<StringError>("ELF note overflows container",
677  }
678 
679  // Advance Nhdr by NoteSize bytes, starting from NhdrPos.
680  //
681  // Assumes NoteSize <= RemainingSize. Ensures Nhdr->getSize() <= RemainingSize
682  // upon returning. Handles stopping iteration when reaching the end of the
683  // container, either cleanly or with an overflow error.
684  void advanceNhdr(const uint8_t *NhdrPos, size_t NoteSize) {
685  RemainingSize -= NoteSize;
686  if (RemainingSize == 0u) {
687  // Ensure that if the iterator walks to the end, the error is checked
688  // afterwards.
689  *Err = Error::success();
690  Nhdr = nullptr;
691  } else if (sizeof(*Nhdr) > RemainingSize)
692  stopWithOverflowError();
693  else {
694  Nhdr = reinterpret_cast<const Elf_Nhdr_Impl<ELFT> *>(NhdrPos + NoteSize);
695  if (Nhdr->getSize() > RemainingSize)
696  stopWithOverflowError();
697  else
698  *Err = Error::success();
699  }
700  }
701 
702  Elf_Note_Iterator_Impl() = default;
703  explicit Elf_Note_Iterator_Impl(Error &Err) : Err(&Err) {}
704  Elf_Note_Iterator_Impl(const uint8_t *Start, size_t Size, Error &Err)
705  : RemainingSize(Size), Err(&Err) {
706  consumeError(std::move(Err));
707  assert(Start && "ELF note iterator starting at NULL");
708  advanceNhdr(Start, 0u);
709  }
710 
711 public:
713  assert(Nhdr && "incremented ELF note end iterator");
714  const uint8_t *NhdrPos = reinterpret_cast<const uint8_t *>(Nhdr);
715  size_t NoteSize = Nhdr->getSize();
716  advanceNhdr(NhdrPos, NoteSize);
717  return *this;
718  }
720  if (!Nhdr && Other.Err)
721  (void)(bool)(*Other.Err);
722  if (!Other.Nhdr && Err)
723  (void)(bool)(*Err);
724  return Nhdr == Other.Nhdr;
725  }
727  return !(*this == Other);
728  }
730  assert(Nhdr && "dereferenced ELF note end iterator");
731  return Elf_Note_Impl<ELFT>(*Nhdr);
732  }
733 };
734 
735 template <class ELFT> struct Elf_CGProfile_Impl {
737  Elf_Xword cgp_weight;
738 };
739 
740 // MIPS .reginfo section
741 template <class ELFT>
743 
744 template <support::endianness TargetEndianness>
745 struct Elf_Mips_RegInfo<ELFType<TargetEndianness, false>> {
746  LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
747  Elf_Word ri_gprmask; // bit-mask of used general registers
748  Elf_Word ri_cprmask[4]; // bit-mask of used co-processor registers
749  Elf_Addr ri_gp_value; // gp register value
750 };
751 
752 template <support::endianness TargetEndianness>
753 struct Elf_Mips_RegInfo<ELFType<TargetEndianness, true>> {
754  LLVM_ELF_IMPORT_TYPES(TargetEndianness, true)
755  Elf_Word ri_gprmask; // bit-mask of used general registers
756  Elf_Word ri_pad; // unused padding field
757  Elf_Word ri_cprmask[4]; // bit-mask of used co-processor registers
758  Elf_Addr ri_gp_value; // gp register value
759 };
760 
761 // .MIPS.options section
762 template <class ELFT> struct Elf_Mips_Options {
764  uint8_t kind; // Determines interpretation of variable part of descriptor
765  uint8_t size; // Byte size of descriptor, including this header
766  Elf_Half section; // Section header index of section affected,
767  // or 0 for global options
768  Elf_Word info; // Kind-specific information
769 
770  Elf_Mips_RegInfo<ELFT> &getRegInfo() {
771  assert(kind == ELF::ODK_REGINFO);
772  return *reinterpret_cast<Elf_Mips_RegInfo<ELFT> *>(
773  (uint8_t *)this + sizeof(Elf_Mips_Options));
774  }
776  return const_cast<Elf_Mips_Options *>(this)->getRegInfo();
777  }
778 };
779 
780 // .MIPS.abiflags section content
781 template <class ELFT> struct Elf_Mips_ABIFlags {
783  Elf_Half version; // Version of the structure
784  uint8_t isa_level; // ISA level: 1-5, 32, and 64
785  uint8_t isa_rev; // ISA revision (0 for MIPS I - MIPS V)
786  uint8_t gpr_size; // General purpose registers size
787  uint8_t cpr1_size; // Co-processor 1 registers size
788  uint8_t cpr2_size; // Co-processor 2 registers size
789  uint8_t fp_abi; // Floating-point ABI flag
790  Elf_Word isa_ext; // Processor-specific extension
791  Elf_Word ases; // ASEs flags
792  Elf_Word flags1; // General flags
793  Elf_Word flags2; // General flags
794 };
795 
796 // Struct representing the BBAddrMap for one function.
797 struct BBAddrMap {
798  uint64_t Addr; // Function address
799  // Struct representing the BBAddrMap information for one basic block.
800  struct BBEntry {
801  uint32_t Offset; // Offset of basic block relative to function start.
802  uint32_t Size; // Size of the basic block.
803 
804  // The following fields are decoded from the Metadata field. The encoding
805  // happens in AsmPrinter.cpp:getBBAddrMapMetadata.
806  bool HasReturn; // If this block ends with a return (or tail call).
807  bool HasTailCall; // If this block ends with a tail call.
808  bool IsEHPad; // If this is an exception handling block.
809  bool CanFallThrough; // If this block can fall through to its next.
810 
812  : Offset(Offset), Size(Size), HasReturn(Metadata & 1),
813  HasTailCall(Metadata & (1 << 1)), IsEHPad(Metadata & (1 << 2)),
814  CanFallThrough(Metadata & (1 << 3)){};
815 
816  bool operator==(const BBEntry &Other) const {
817  return Offset == Other.Offset && Size == Other.Size &&
818  HasReturn == Other.HasReturn && HasTailCall == Other.HasTailCall &&
819  IsEHPad == Other.IsEHPad && CanFallThrough == Other.CanFallThrough;
820  }
821  };
822  std::vector<BBEntry> BBEntries; // Basic block entries for this function.
823 
824  // Equality operator for unit testing.
825  bool operator==(const BBAddrMap &Other) const {
826  return Addr == Other.Addr && std::equal(BBEntries.begin(), BBEntries.end(),
827  Other.BBEntries.begin());
828  }
829 };
830 
831 } // end namespace object.
832 } // end namespace llvm.
833 
834 #endif // LLVM_OBJECT_ELFTYPES_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:77
llvm::object::Elf_Mips_Options::getRegInfo
const Elf_Mips_RegInfo< ELFT > & getRegInfo() const
Definition: ELFTypes.h:775
llvm::alignTo
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:156
llvm::object::Elf_Chdr_Impl
Definition: ELFTypes.h:42
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, false >, false >::getSymbol
uint32_t getSymbol(bool isMips64EL) const
Definition: ELFTypes.h:401
getName
static StringRef getName(Value *V)
Definition: ProvenanceAnalysisEvaluator.cpp:42
MathExtras.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::HexagonMCInstrInfo::getDesc
const MCInstrDesc & getDesc(MCInstrInfo const &MCII, MCInst const &MCI)
Definition: HexagonMCInstrInfo.cpp:255
llvm::object::Elf_Shdr_Impl::getEntityCount
unsigned getEntityCount() const
Get the number of entities this section contains if it has any.
Definition: ELFTypes.h:183
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
llvm::ELF::EI_DATA
@ EI_DATA
Definition: ELF.h:53
endianness
llvm::support::endianness endianness
Definition: BinaryStreamReader.cpp:16
llvm::object::Elf_Ehdr_Impl
Definition: ELFTypes.h:29
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, true >, false >::setSymbolAndType
void setSymbolAndType(uint32_t s, uint32_t t, bool IsMips64EL)
Definition: ELFTypes.h:466
llvm::support::detail::packed_endian_specific_integral
Definition: Endian.h:206
StringRef.h
llvm::object::BBAddrMap::Addr
uint64_t Addr
Definition: ELFTypes.h:798
llvm::object::ELFType::TargetEndianness
static const endianness TargetEndianness
Definition: ELFTypes.h:54
llvm::object::Elf_Sym_Impl::getType
unsigned char getType() const
Definition: ELFTypes.h:224
llvm::ELF::SHN_LOPROC
@ SHN_LOPROC
Definition: ELF.h:942
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
llvm::object::Elf_Dyn_Impl
Elf_Dyn_Impl: This inherits from Elf_Dyn_Base, adding getters.
Definition: ELFTypes.h:32
llvm::object::Elf_Sym_Impl::isOSSpecific
bool isOSSpecific() const
Definition: ELFTypes.h:256
memcmp
Merge contiguous icmps into a memcmp
Definition: MergeICmps.cpp:899
Error.h
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, true >, false >::getType
uint32_t getType(bool isMips64EL) const
Definition: ELFTypes.h:457
llvm::object::Elf_Rel_Impl
Definition: ELFTypes.h:34
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, false >, false >::setRInfo
void setRInfo(uint32_t R, bool IsMips64EL)
Definition: ELFTypes.h:394
llvm::ELF::SHN_LOOS
@ SHN_LOOS
Definition: ELF.h:944
llvm::object::ELFType::Is64Bits
static const bool Is64Bits
Definition: ELFTypes.h:55
LLVM_ELF_IMPORT_TYPES
#define LLVM_ELF_IMPORT_TYPES(E, W)
Definition: ELFTypes.h:141
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1886
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, false >, false >::setSymbol
void setSymbol(uint32_t s, bool IsMips64EL)
Definition: ELFTypes.h:407
llvm::ELF::SHN_HIPROC
@ SHN_HIPROC
Definition: ELF.h:943
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:235
llvm::object::Elf_Sym_Impl::getValue
uint64_t getValue() const
Definition: ELFTypes.h:225
llvm::object::Elf_Mips_ABIFlags
Definition: ELFTypes.h:781
llvm::object::Elf_Dyn_Impl::getVal
uintX_t getVal() const
Definition: ELFTypes.h:379
llvm::object::Elf_Note_Impl::Elf_Note_Impl
Elf_Note_Impl(const Elf_Nhdr_Impl< ELFT > &Nhdr)
Definition: ELFTypes.h:626
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::object::Elf_Verdaux_Impl
Elf_Verdaux: This is the structure of auxiliary data in the SHT_GNU_verdef section (....
Definition: ELFTypes.h:36
llvm::object::Elf_Sym_Impl::getVisibility
unsigned char getVisibility() const
Access to the STV_xxx flag stored in the first two bits of st_other.
Definition: ELFTypes.h:238
llvm::object::BBAddrMap::BBEntry::Offset
uint32_t Offset
Definition: ELFTypes.h:801
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1043
llvm::object::Elf_Note_Iterator_Impl::operator!=
bool operator!=(Elf_Note_Iterator_Impl Other) const
Definition: ELFTypes.h:726
llvm::ArrayRef::data
const T * data() const
Definition: ArrayRef.h:161
llvm::ELF::SHN_COMMON
@ SHN_COMMON
Definition: ELF.h:947
llvm::object::Elf_Hash_Impl
Definition: ELFTypes.h:40
llvm::lltok::equal
@ equal
Definition: LLToken.h:25
llvm::object::Elf_Sym_Impl::setType
void setType(unsigned char t)
Definition: ELFTypes.h:227
llvm::object::BBAddrMap::BBEntry::HasTailCall
bool HasTailCall
Definition: ELFTypes.h:807
llvm::object::ELFType
Definition: ELFTypes.h:48
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, false >, false >::setSymbolAndType
void setSymbolAndType(uint32_t s, unsigned char t, bool IsMips64EL)
Definition: ELFTypes.h:413
llvm::Intrinsic::getType
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
Definition: Function.cpp:1374
llvm::object::Elf_Versym_Impl
Elf_Versym: This is the structure of entries in the SHT_GNU_versym section (.gnu.version).
Definition: ELFTypes.h:39
Error.h
ELF.h
llvm::object::BBAddrMap::BBEntry
Definition: ELFTypes.h:800
llvm::object::Elf_Sym_Impl::getName
Expected< StringRef > getName(StringRef StrTab) const
Definition: ELFTypes.h:276
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::object::Elf_Sym_Impl::isDefined
bool isDefined() const
Definition: ELFTypes.h:250
llvm::object::Elf_Dyn_Impl::intX_t
std::conditional_t< ELFT::Is64Bits, int64_t, int32_t > intX_t
Definition: ELFTypes.h:376
llvm::object::Elf_GnuHash_Impl::buckets
ArrayRef< Elf_Word > buckets() const
Definition: ELFTypes.h:563
llvm::object::BBAddrMap::BBEntry::CanFallThrough
bool CanFallThrough
Definition: ELFTypes.h:809
t
bitcast float %x to i32 %s=and i32 %t, 2147483647 %d=bitcast i32 %s to float ret float %d } declare float @fabsf(float %n) define float @bar(float %x) nounwind { %d=call float @fabsf(float %x) ret float %d } This IR(from PR6194):target datalayout="e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target triple="x86_64-apple-darwin10.0.0" %0=type { double, double } %struct.float3=type { float, float, float } define void @test(%0, %struct.float3 *nocapture %res) nounwind noinline ssp { entry:%tmp18=extractvalue %0 %0, 0 t
Definition: README-SSE.txt:788
b
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 int b
Definition: README.txt:418
false
Definition: StackSlotColoring.cpp:141
llvm::ELF::SHN_ABS
@ SHN_ABS
Definition: ELF.h:946
llvm::object::object_error::parse_failed
@ parse_failed
llvm::object::Elf_Mips_RegInfo
Definition: ELFTypes.h:742
llvm::object::Elf_Shdr_Impl
Definition: ELFTypes.h:30
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::object::Elf_Sym_Impl::isReserved
bool isReserved() const
Definition: ELFTypes.h:260
llvm::object::Elf_Dyn_Base< ELFType< TargetEndianness, true > >::d_val
Elf_Xword d_val
Definition: ELFTypes.h:366
llvm::object::BBAddrMap::BBEntry::operator==
bool operator==(const BBEntry &Other) const
Definition: ELFTypes.h:816
llvm::object::Elf_Sym_Impl::setBinding
void setBinding(unsigned char b)
Definition: ELFTypes.h:226
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:33
llvm::object::Elf_Sym_Impl::isUndefined
bool isUndefined() const
Definition: ELFTypes.h:266
uint64_t
llvm::object::Elf_Sym_Impl::isAbsolute
bool isAbsolute() const
Definition: ELFTypes.h:244
llvm::ELF::EI_CLASS
@ EI_CLASS
Definition: ELF.h:52
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:78
llvm::ELF::STB_LOCAL
@ STB_LOCAL
Definition: ELF.h:1188
s
multiplies can be turned into SHL s
Definition: README.txt:370
llvm::object::ELFType::uint
std::conditional_t< Is64, uint64_t, uint32_t > uint
Definition: ELFTypes.h:57
llvm::object::BBAddrMap::BBEntry::Size
uint32_t Size
Definition: ELFTypes.h:802
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::object::BBAddrMap::BBEntry::IsEHPad
bool IsEHPad
Definition: ELFTypes.h:808
llvm::object::Elf_Dyn_Base
Elf_Dyn_Base: This structure matches the form of entries in the dynamic table section (....
Definition: ELFTypes.h:349
llvm::object::Elf_Note_Iterator_Impl::difference_type
std::ptrdiff_t difference_type
Definition: ELFTypes.h:660
ArrayRef.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::object::Elf_Verneed_Impl
Elf_Verneed: This is the structure of entries in the SHT_GNU_verneed section (.gnu....
Definition: ELFTypes.h:37
isMips64EL
static bool isMips64EL(const ELFYAML::Object &Obj)
Definition: ELFEmitter.cpp:1259
llvm::object::Elf_Note_Iterator_Impl::operator*
Elf_Note_Impl< ELFT > operator*() const
Definition: ELFTypes.h:729
llvm::object::Elf_CGProfile_Impl
Definition: ELFTypes.h:46
llvm::object::Elf_Nhdr_Impl::n_descsz
Elf_Word n_descsz
Definition: ELFTypes.h:598
llvm::object::Elf_Sym_Impl::setVisibility
void setVisibility(unsigned char v)
Definition: ELFTypes.h:239
info
lazy value info
Definition: LazyValueInfo.cpp:58
llvm::object::BBAddrMap::operator==
bool operator==(const BBAddrMap &Other) const
Definition: ELFTypes.h:825
llvm::object::BBAddrMap::BBEntry::BBEntry
BBEntry(uint32_t Offset, uint32_t Size, uint32_t Metadata)
Definition: ELFTypes.h:811
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, true >, false >::setRInfo
void setRInfo(uint64_t R, bool IsMips64EL)
Definition: ELFTypes.h:444
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:1598
llvm::object::Elf_Note_Iterator_Impl::operator==
bool operator==(Elf_Note_Iterator_Impl Other) const
Definition: ELFTypes.h:719
llvm::object::Elf_Shdr_Base
Definition: ELFTypes.h:145
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, true >, false >::getSymbol
uint32_t getSymbol(bool isMips64EL) const
Definition: ELFTypes.h:454
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::object::Elf_Hash_Impl::chains
ArrayRef< Elf_Word > chains() const
Definition: ELFTypes.h:543
uint32_t
llvm::object::Elf_Sym_Impl
Definition: ELFTypes.h:31
llvm::ELF::SHN_LORESERVE
@ SHN_LORESERVE
Definition: ELF.h:941
llvm::object::Elf_Note_Iterator_Impl
Definition: ELFTypes.h:45
llvm::object::BBAddrMap
Definition: ELFTypes.h:797
llvm::object::Elf_Sym_Base
Definition: ELFTypes.h:190
llvm::object::Elf_Dyn_Base< ELFType< TargetEndianness, false > >::d_val
Elf_Word d_val
Definition: ELFTypes.h:356
llvm::object::Elf_Sym_Impl::isProcessorSpecific
bool isProcessorSpecific() const
Definition: ELFTypes.h:252
llvm::object::Elf_Note_Impl::getDescAsStringRef
StringRef getDescAsStringRef() const
Get the note's descriptor as StringRef.
Definition: ELFTypes.h:647
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, false >, false >::setType
void setType(unsigned char t, bool IsMips64EL)
Definition: ELFTypes.h:410
llvm::object::Elf_Ehdr_Impl::getDataEncoding
unsigned char getDataEncoding() const
Definition: ELFTypes.h:503
LLVM_ELF_IMPORT_TYPES_ELFT
#define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
Definition: ELFTypes.h:104
llvm::object::Elf_Sym_Impl::getBinding
unsigned char getBinding() const
Definition: ELFTypes.h:223
llvm::StringRef::size
constexpr LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:157
llvm::object::Elf_Verdef_Impl
Elf_Verdef: This is the structure of entries in the SHT_GNU_verdef section (.gnu.version_d).
Definition: ELFTypes.h:35
llvm::ELF::SHN_HIOS
@ SHN_HIOS
Definition: ELF.h:945
llvm::createStringError
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1239
llvm::object::BBAddrMap::BBEntry::HasReturn
bool HasReturn
Definition: ELFTypes.h:806
llvm::object::Elf_Sym_Impl::isCommon
bool isCommon() const
Definition: ELFTypes.h:246
llvm::object::BBAddrMap::BBEntries
std::vector< BBEntry > BBEntries
Definition: ELFTypes.h:822
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::object::Elf_Mips_Options
Definition: ELFTypes.h:762
llvm::object::Elf_Nhdr_Impl::getSize
size_t getSize() const
Get the size of the note, including name, descriptor, and padding.
Definition: ELFTypes.h:608
llvm::object::Elf_Note_Iterator_Impl::operator++
Elf_Note_Iterator_Impl & operator++()
Definition: ELFTypes.h:712
llvm::object::Elf_Vernaux_Impl
Elf_Vernaux: This is the structure of auxiliary data in SHT_GNU_verneed section (....
Definition: ELFTypes.h:38
llvm::object::Elf_Note_Impl::getDesc
ArrayRef< uint8_t > getDesc() const
Get the note's descriptor.
Definition: ELFTypes.h:637
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, false >, false >::getType
unsigned char getType(bool isMips64EL) const
Definition: ELFTypes.h:404
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, true >, false >::setType
void setType(uint32_t t, bool IsMips64EL)
Definition: ELFTypes.h:463
llvm::object::Elf_Sym_Impl::isExternal
bool isExternal() const
Definition: ELFTypes.h:268
llvm::object::Elf_GnuHash_Impl::values
ArrayRef< Elf_Word > values(unsigned DynamicSymCount) const
Definition: ELFTypes.h:568
llvm::ELF::ElfMagic
static const char ElfMagic[]
Definition: ELF.h:44
llvm::ELF::ODK_REGINFO
@ ODK_REGINFO
Definition: ELF.h:593
llvm::object::Elf_Dyn_Impl::uintX_t
std::conditional_t< ELFT::Is64Bits, uint64_t, uint32_t > uintX_t
Definition: ELFTypes.h:377
llvm::ELF::EI_NIDENT
@ EI_NIDENT
Definition: ELF.h:58
llvm::ELF::SHN_UNDEF
@ SHN_UNDEF
Definition: ELF.h:940
llvm::object::Elf_Sym_Impl::setBindingAndType
void setBindingAndType(unsigned char b, unsigned char t)
Definition: ELFTypes.h:229
llvm::object::Elf_Note_Iterator_Impl::iterator_category
std::forward_iterator_tag iterator_category
Definition: ELFTypes.h:658
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:164
support
Reimplement select in terms of SEL *We would really like to support but we need to prove that the add doesn t need to overflow between the two bit chunks *Implement pre post increment support(e.g. PR935) *Implement smarter const ant generation for binops with large immediates. A few ARMv6T2 ops should be pattern matched
Definition: README.txt:10
llvm::object::Elf_GnuHash_Impl
Definition: ELFTypes.h:41
llvm::support::endianness
endianness
Definition: Endian.h:27
llvm::StringRef::data
const LLVM_NODISCARD char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:149
llvm::object::Elf_Rel_Impl< ELFType< TargetEndianness, true >, false >::setSymbol
void setSymbol(uint32_t s, bool IsMips64EL)
Definition: ELFTypes.h:460
llvm::object::Elf_Dyn_Impl::getTag
intX_t getTag() const
Definition: ELFTypes.h:378
llvm::object::Elf_Note_Impl
An ELF note.
Definition: ELFTypes.h:44
llvm::object::Elf_Dyn_Base< ELFType< TargetEndianness, true > >::d_ptr
Elf_Addr d_ptr
Definition: ELFTypes.h:367
llvm::object::Elf_Dyn_Base< ELFType< TargetEndianness, false > >::d_ptr
Elf_Addr d_ptr
Definition: ELFTypes.h:357
Endian.h
llvm::object::Elf_Ehdr_Impl::getFileClass
unsigned char getFileClass() const
Definition: ELFTypes.h:502
llvm::ELF::STT_COMMON
@ STT_COMMON
Definition: ELF.h:1205
llvm::object::ELFFile
Definition: ELF.h:94
llvm::object::Elf_Note_Impl::getName
StringRef getName() const
Get the note's name, excluding the terminating null byte.
Definition: ELFTypes.h:629
llvm::object::Elf_Note_Impl::getType
Elf_Word getType() const
Get the note's type.
Definition: ELFTypes.h:653
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1236
llvm::object::Elf_Nhdr_Impl
Note header.
Definition: ELFTypes.h:43
llvm::object::Elf_Dyn_Impl::getPtr
uintX_t getPtr() const
Definition: ELFTypes.h:380