LLVM 22.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"
15#include "llvm/Object/Error.h"
18#include "llvm/Support/Endian.h"
19#include "llvm/Support/Error.h"
22#include <cassert>
23#include <cstdint>
24#include <cstring>
25#include <type_traits>
26
27namespace llvm {
28namespace object {
29
30template <class ELFT> struct Elf_Ehdr_Impl;
31template <class ELFT> struct Elf_Shdr_Impl;
32template <class ELFT> struct Elf_Sym_Impl;
33template <class ELFT> struct Elf_Dyn_Impl;
34template <class ELFT> struct Elf_Phdr_Impl;
35template <class ELFT, bool isRela> struct Elf_Rel_Impl;
36template <bool Is64> struct Elf_Crel_Impl;
37template <class ELFT> struct Elf_Verdef_Impl;
38template <class ELFT> struct Elf_Verdaux_Impl;
39template <class ELFT> struct Elf_Verneed_Impl;
40template <class ELFT> struct Elf_Vernaux_Impl;
41template <class ELFT> struct Elf_Versym_Impl;
42template <class ELFT> struct Elf_Hash_Impl;
43template <class ELFT> struct Elf_GnuHash_Impl;
44template <class ELFT> struct Elf_Chdr_Impl;
45template <class ELFT> struct Elf_Nhdr_Impl;
46template <class ELFT> class Elf_Note_Impl;
47template <class ELFT> class Elf_Note_Iterator_Impl;
48template <class ELFT> struct Elf_CGProfile_Impl;
49
50template <endianness E, bool Is64> struct ELFType {
51private:
52 template <typename Ty>
54
55public:
56 static const endianness Endianness = E;
57 static const bool Is64Bits = Is64;
58
59 using uint = std::conditional_t<Is64, uint64_t, uint32_t>;
88
96};
97
102
103// Use an alignment of 2 for the typedefs since that is the worst case for
104// ELF files in archives.
105
106// I really don't like doing this, but the alternative is copypasta.
107#define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) \
108 using Elf_Addr = typename ELFT::Addr; \
109 using Elf_Off = typename ELFT::Off; \
110 using Elf_Half = typename ELFT::Half; \
111 using Elf_Word = typename ELFT::Word; \
112 using Elf_Sword = typename ELFT::Sword; \
113 using Elf_Xword = typename ELFT::Xword; \
114 using Elf_Sxword = typename ELFT::Sxword; \
115 using uintX_t = typename ELFT::uint; \
116 using Elf_Ehdr = typename ELFT::Ehdr; \
117 using Elf_Shdr = typename ELFT::Shdr; \
118 using Elf_Sym = typename ELFT::Sym; \
119 using Elf_Dyn = typename ELFT::Dyn; \
120 using Elf_Phdr = typename ELFT::Phdr; \
121 using Elf_Rel = typename ELFT::Rel; \
122 using Elf_Rela = typename ELFT::Rela; \
123 using Elf_Crel = typename ELFT::Crel; \
124 using Elf_Relr = typename ELFT::Relr; \
125 using Elf_Verdef = typename ELFT::Verdef; \
126 using Elf_Verdaux = typename ELFT::Verdaux; \
127 using Elf_Verneed = typename ELFT::Verneed; \
128 using Elf_Vernaux = typename ELFT::Vernaux; \
129 using Elf_Versym = typename ELFT::Versym; \
130 using Elf_Hash = typename ELFT::Hash; \
131 using Elf_GnuHash = typename ELFT::GnuHash; \
132 using Elf_Chdr = typename ELFT::Chdr; \
133 using Elf_Nhdr = typename ELFT::Nhdr; \
134 using Elf_Note = typename ELFT::Note; \
135 using Elf_Note_Iterator = typename ELFT::NoteIterator; \
136 using Elf_CGProfile = typename ELFT::CGProfile; \
137 using Elf_Dyn_Range = typename ELFT::DynRange; \
138 using Elf_Shdr_Range = typename ELFT::ShdrRange; \
139 using Elf_Sym_Range = typename ELFT::SymRange; \
140 using Elf_Rel_Range = typename ELFT::RelRange; \
141 using Elf_Rela_Range = typename ELFT::RelaRange; \
142 using Elf_Relr_Range = typename ELFT::RelrRange; \
143 using Elf_Phdr_Range = typename ELFT::PhdrRange;
144
145#define LLVM_ELF_COMMA ,
146#define LLVM_ELF_IMPORT_TYPES(E, W) \
147 LLVM_ELF_IMPORT_TYPES_ELFT(ELFType<E LLVM_ELF_COMMA W>)
148
149// Section header.
150template <class ELFT> struct Elf_Shdr_Base;
151
152template <endianness Endianness>
153struct Elf_Shdr_Base<ELFType<Endianness, false>> {
154 LLVM_ELF_IMPORT_TYPES(Endianness, false)
155 Elf_Word sh_name; // Section name (index into string table)
156 Elf_Word sh_type; // Section type (SHT_*)
157 Elf_Word sh_flags; // Section flags (SHF_*)
158 Elf_Addr sh_addr; // Address where section is to be loaded
159 Elf_Off sh_offset; // File offset of section data, in bytes
160 Elf_Word sh_size; // Size of section, in bytes
161 Elf_Word sh_link; // Section type-specific header table index link
162 Elf_Word sh_info; // Section type-specific extra information
163 Elf_Word sh_addralign; // Section address alignment
164 Elf_Word sh_entsize; // Size of records contained within the section
165};
166
167template <endianness Endianness>
168struct Elf_Shdr_Base<ELFType<Endianness, true>> {
169 LLVM_ELF_IMPORT_TYPES(Endianness, true)
170 Elf_Word sh_name; // Section name (index into string table)
171 Elf_Word sh_type; // Section type (SHT_*)
172 Elf_Xword sh_flags; // Section flags (SHF_*)
173 Elf_Addr sh_addr; // Address where section is to be loaded
174 Elf_Off sh_offset; // File offset of section data, in bytes
175 Elf_Xword sh_size; // Size of section, in bytes
176 Elf_Word sh_link; // Section type-specific header table index link
177 Elf_Word sh_info; // Section type-specific extra information
178 Elf_Xword sh_addralign; // Section address alignment
179 Elf_Xword sh_entsize; // Size of records contained within the section
180};
181
182template <class ELFT>
184 using Elf_Shdr_Base<ELFT>::sh_entsize;
185 using Elf_Shdr_Base<ELFT>::sh_size;
186
187 /// Get the number of entities this section contains if it has any.
188 unsigned getEntityCount() const {
189 if (sh_entsize == 0)
190 return 0;
191 return sh_size / sh_entsize;
192 }
193};
194
195template <class ELFT> struct Elf_Sym_Base;
196
197template <endianness Endianness>
198struct Elf_Sym_Base<ELFType<Endianness, false>> {
199 LLVM_ELF_IMPORT_TYPES(Endianness, false)
200 Elf_Word st_name; // Symbol name (index into string table)
201 Elf_Addr st_value; // Value or address associated with the symbol
202 Elf_Word st_size; // Size of the symbol
203 unsigned char st_info; // Symbol's type and binding attributes
204 unsigned char st_other; // Must be zero; reserved
205 Elf_Half st_shndx; // Which section (header table index) it's defined in
206};
207
208template <endianness Endianness>
209struct Elf_Sym_Base<ELFType<Endianness, true>> {
210 LLVM_ELF_IMPORT_TYPES(Endianness, true)
211 Elf_Word st_name; // Symbol name (index into string table)
212 unsigned char st_info; // Symbol's type and binding attributes
213 unsigned char st_other; // Must be zero; reserved
214 Elf_Half st_shndx; // Which section (header table index) it's defined in
215 Elf_Addr st_value; // Value or address associated with the symbol
216 Elf_Xword st_size; // Size of the symbol
217};
218
219template <class ELFT>
221 using Elf_Sym_Base<ELFT>::st_info;
222 using Elf_Sym_Base<ELFT>::st_shndx;
223 using Elf_Sym_Base<ELFT>::st_other;
224 using Elf_Sym_Base<ELFT>::st_value;
225
226 // These accessors and mutators correspond to the ELF32_ST_BIND,
227 // ELF32_ST_TYPE, and ELF32_ST_INFO macros defined in the ELF specification:
228 unsigned char getBinding() const { return st_info >> 4; }
229 unsigned char getType() const { return st_info & 0x0f; }
230 uint64_t getValue() const { return st_value; }
231 void setBinding(unsigned char b) { setBindingAndType(b, getType()); }
232 void setType(unsigned char t) { setBindingAndType(getBinding(), t); }
233
234 void setBindingAndType(unsigned char b, unsigned char t) {
235 st_info = (b << 4) + (t & 0x0f);
236 }
237
238 /// Access to the STV_xxx flag stored in the first two bits of st_other.
239 /// STV_DEFAULT: 0
240 /// STV_INTERNAL: 1
241 /// STV_HIDDEN: 2
242 /// STV_PROTECTED: 3
243 unsigned char getVisibility() const { return st_other & 0x3; }
244 void setVisibility(unsigned char v) {
245 assert(v < 4 && "Invalid value for visibility");
246 st_other = (st_other & ~0x3) | v;
247 }
248
249 bool isAbsolute() const { return st_shndx == ELF::SHN_ABS; }
250
251 bool isCommon() const {
252 return getType() == ELF::STT_COMMON || st_shndx == ELF::SHN_COMMON;
253 }
254
255 bool isDefined() const { return !isUndefined(); }
256
257 bool isProcessorSpecific() const {
258 return st_shndx >= ELF::SHN_LOPROC && st_shndx <= ELF::SHN_HIPROC;
259 }
260
261 bool isOSSpecific() const {
262 return st_shndx >= ELF::SHN_LOOS && st_shndx <= ELF::SHN_HIOS;
263 }
264
265 bool isReserved() const {
266 // ELF::SHN_HIRESERVE is 0xffff so st_shndx <= ELF::SHN_HIRESERVE is always
267 // true and some compilers warn about it.
268 return st_shndx >= ELF::SHN_LORESERVE;
269 }
270
271 bool isUndefined() const { return st_shndx == ELF::SHN_UNDEF; }
272
273 bool isExternal() const {
274 return getBinding() != ELF::STB_LOCAL;
275 }
276
278};
279
280template <class ELFT>
282 uint32_t Offset = this->st_name;
283 if (Offset >= StrTab.size())
284 return createStringError(object_error::parse_failed,
285 "st_name (0x%" PRIx32
286 ") is past the end of the string table"
287 " of size 0x%zx",
288 Offset, StrTab.size());
289 return StringRef(StrTab.data() + Offset);
290}
291
292/// Elf_Versym: This is the structure of entries in the SHT_GNU_versym section
293/// (.gnu.version). This structure is identical for ELF32 and ELF64.
294template <class ELFT>
297 Elf_Half vs_index; // Version index with flags (e.g. VERSYM_HIDDEN)
298};
299
300/// Elf_Verdef: This is the structure of entries in the SHT_GNU_verdef section
301/// (.gnu.version_d). This structure is identical for ELF32 and ELF64.
302template <class ELFT>
305 Elf_Half vd_version; // Version of this structure (e.g. VER_DEF_CURRENT)
306 Elf_Half vd_flags; // Bitwise flags (VER_DEF_*)
307 Elf_Half vd_ndx; // Version index, used in .gnu.version entries
308 Elf_Half vd_cnt; // Number of Verdaux entries
309 Elf_Word vd_hash; // Hash of name
310 Elf_Word vd_aux; // Offset to the first Verdaux entry (in bytes)
311 Elf_Word vd_next; // Offset to the next Verdef entry (in bytes)
312
313 /// Get the first Verdaux entry for this Verdef.
314 const Elf_Verdaux *getAux() const {
315 return reinterpret_cast<const Elf_Verdaux *>((const char *)this + vd_aux);
316 }
317};
318
319/// Elf_Verdaux: This is the structure of auxiliary data in the SHT_GNU_verdef
320/// section (.gnu.version_d). This structure is identical for ELF32 and ELF64.
321template <class ELFT>
324 Elf_Word vda_name; // Version name (offset in string table)
325 Elf_Word vda_next; // Offset to next Verdaux entry (in bytes)
326};
327
328/// Elf_Verneed: This is the structure of entries in the SHT_GNU_verneed
329/// section (.gnu.version_r). This structure is identical for ELF32 and ELF64.
330template <class ELFT>
333 Elf_Half vn_version; // Version of this structure (e.g. VER_NEED_CURRENT)
334 Elf_Half vn_cnt; // Number of associated Vernaux entries
335 Elf_Word vn_file; // Library name (string table offset)
336 Elf_Word vn_aux; // Offset to first Vernaux entry (in bytes)
337 Elf_Word vn_next; // Offset to next Verneed entry (in bytes)
338};
339
340/// Elf_Vernaux: This is the structure of auxiliary data in SHT_GNU_verneed
341/// section (.gnu.version_r). This structure is identical for ELF32 and ELF64.
342template <class ELFT>
345 Elf_Word vna_hash; // Hash of dependency name
346 Elf_Half vna_flags; // Bitwise Flags (VER_FLAG_*)
347 Elf_Half vna_other; // Version index, used in .gnu.version entries
348 Elf_Word vna_name; // Dependency name
349 Elf_Word vna_next; // Offset to next Vernaux entry (in bytes)
350};
351
352/// Elf_Dyn_Base: This structure matches the form of entries in the dynamic
353/// table section (.dynamic) look like.
354template <class ELFT> struct Elf_Dyn_Base;
355
356template <endianness Endianness>
357struct Elf_Dyn_Base<ELFType<Endianness, false>> {
358 LLVM_ELF_IMPORT_TYPES(Endianness, false)
359 Elf_Sword d_tag;
360 union {
361 Elf_Word d_val;
362 Elf_Addr d_ptr;
363 } d_un;
364};
365
366template <endianness Endianness>
367struct Elf_Dyn_Base<ELFType<Endianness, true>> {
368 LLVM_ELF_IMPORT_TYPES(Endianness, true)
369 Elf_Sxword d_tag;
370 union {
371 Elf_Xword d_val;
372 Elf_Addr d_ptr;
373 } d_un;
374};
375
376/// Elf_Dyn_Impl: This inherits from Elf_Dyn_Base, adding getters.
377template <class ELFT>
379 using Elf_Dyn_Base<ELFT>::d_tag;
380 using Elf_Dyn_Base<ELFT>::d_un;
381 using intX_t = std::conditional_t<ELFT::Is64Bits, int64_t, int32_t>;
382 using uintX_t = std::conditional_t<ELFT::Is64Bits, uint64_t, uint32_t>;
383 intX_t getTag() const { return d_tag; }
384 uintX_t getVal() const { return d_un.d_val; }
385 uintX_t getPtr() const { return d_un.d_ptr; }
386};
387
388template <endianness Endianness>
389struct Elf_Rel_Impl<ELFType<Endianness, false>, false> {
390 LLVM_ELF_IMPORT_TYPES(Endianness, false)
391 static const bool HasAddend = false;
392 static const bool IsCrel = false;
393 Elf_Addr r_offset; // Location (file byte offset, or program virtual addr)
394 Elf_Word r_info; // Symbol table index and type of relocation to apply
395
396 uint32_t getRInfo(bool isMips64EL) const {
398 return r_info;
399 }
400 void setRInfo(uint32_t R, bool IsMips64EL) {
401 assert(!IsMips64EL);
402 r_info = R;
403 }
404
405 // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
406 // and ELF32_R_INFO macros defined in the ELF specification:
408 return this->getRInfo(isMips64EL) >> 8;
409 }
410 unsigned char getType(bool isMips64EL) const {
411 return (unsigned char)(this->getRInfo(isMips64EL) & 0x0ff);
412 }
413 void setSymbol(uint32_t s, bool IsMips64EL) {
414 setSymbolAndType(s, getType(IsMips64EL), IsMips64EL);
415 }
416 void setType(unsigned char t, bool IsMips64EL) {
417 setSymbolAndType(getSymbol(IsMips64EL), t, IsMips64EL);
418 }
419 void setSymbolAndType(uint32_t s, unsigned char t, bool IsMips64EL) {
420 this->setRInfo((s << 8) + t, IsMips64EL);
421 }
422};
423
424template <endianness Endianness>
425struct Elf_Rel_Impl<ELFType<Endianness, false>, true>
426 : public Elf_Rel_Impl<ELFType<Endianness, false>, false> {
427 LLVM_ELF_IMPORT_TYPES(Endianness, false)
428 static const bool HasAddend = true;
429 static const bool IsCrel = false;
430 Elf_Sword r_addend; // Compute value for relocatable field by adding this
431};
432
433template <endianness Endianness>
434struct Elf_Rel_Impl<ELFType<Endianness, true>, false> {
435 LLVM_ELF_IMPORT_TYPES(Endianness, true)
436 static const bool HasAddend = false;
437 static const bool IsCrel = false;
438 Elf_Addr r_offset; // Location (file byte offset, or program virtual addr)
439 Elf_Xword r_info; // Symbol table index and type of relocation to apply
440
441 uint64_t getRInfo(bool isMips64EL) const {
442 uint64_t t = r_info;
443 if (!isMips64EL)
444 return t;
445 // Mips64 little endian has a "special" encoding of r_info. Instead of one
446 // 64 bit little endian number, it is a little endian 32 bit number followed
447 // by a 32 bit big endian number.
448 return (t << 32) | ((t >> 8) & 0xff000000) | ((t >> 24) & 0x00ff0000) |
449 ((t >> 40) & 0x0000ff00) | ((t >> 56) & 0x000000ff);
450 }
451
452 void setRInfo(uint64_t R, bool IsMips64EL) {
453 if (IsMips64EL)
454 r_info = (R >> 32) | ((R & 0xff000000) << 8) | ((R & 0x00ff0000) << 24) |
455 ((R & 0x0000ff00) << 40) | ((R & 0x000000ff) << 56);
456 else
457 r_info = R;
458 }
459
460 // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE,
461 // and ELF64_R_INFO macros defined in the ELF specification:
463 return (uint32_t)(this->getRInfo(isMips64EL) >> 32);
464 }
466 return (uint32_t)(this->getRInfo(isMips64EL) & 0xffffffffL);
467 }
468 void setSymbol(uint32_t s, bool IsMips64EL) {
469 setSymbolAndType(s, getType(IsMips64EL), IsMips64EL);
470 }
471 void setType(uint32_t t, bool IsMips64EL) {
472 setSymbolAndType(getSymbol(IsMips64EL), t, IsMips64EL);
473 }
474 void setSymbolAndType(uint32_t s, uint32_t t, bool IsMips64EL) {
475 this->setRInfo(((uint64_t)s << 32) + (t & 0xffffffffL), IsMips64EL);
476 }
477};
478
479template <endianness Endianness>
480struct Elf_Rel_Impl<ELFType<Endianness, true>, true>
481 : public Elf_Rel_Impl<ELFType<Endianness, true>, false> {
482 LLVM_ELF_IMPORT_TYPES(Endianness, true)
483 static const bool HasAddend = true;
484 static const bool IsCrel = false;
485 Elf_Sxword r_addend; // Compute value for relocatable field by adding this.
486};
487
488// In-memory representation. The serialized representation uses LEB128.
489template <bool Is64> struct Elf_Crel_Impl {
490 using uint = std::conditional_t<Is64, uint64_t, uint32_t>;
491 static const bool HasAddend = true;
492 static const bool IsCrel = true;
496 std::conditional_t<Is64, int64_t, int32_t> r_addend;
497
498 // Dummy bool parameter is for compatibility with Elf_Rel_Impl.
499 uint32_t getType(bool) const { return r_type; }
500 uint32_t getSymbol(bool) const { return r_symidx; }
501 void setSymbolAndType(uint32_t s, unsigned char t, bool) {
502 r_symidx = s;
503 r_type = t;
504 }
505};
506
507template <class ELFT>
510 unsigned char e_ident[ELF::EI_NIDENT]; // ELF Identification bytes
511 Elf_Half e_type; // Type of file (see ET_*)
512 Elf_Half e_machine; // Required architecture for this file (see EM_*)
513 Elf_Word e_version; // Must be equal to 1
514 Elf_Addr e_entry; // Address to jump to in order to start program
515 Elf_Off e_phoff; // Program header table's file offset, in bytes
516 Elf_Off e_shoff; // Section header table's file offset, in bytes
517 Elf_Word e_flags; // Processor-specific flags
518 Elf_Half e_ehsize; // Size of ELF header, in bytes
519 Elf_Half e_phentsize; // Size of an entry in the program header table
520 Elf_Half e_phnum; // Number of entries in the program header table
521 Elf_Half e_shentsize; // Size of an entry in the section header table
522 Elf_Half e_shnum; // Number of entries in the section header table
523 Elf_Half e_shstrndx; // Section header table index of section name
524 // string table
525
526 bool checkMagic() const {
527 return (memcmp(e_ident, ELF::ElfMagic, strlen(ELF::ElfMagic))) == 0;
528 }
529
530 unsigned char getFileClass() const { return e_ident[ELF::EI_CLASS]; }
531 unsigned char getDataEncoding() const { return e_ident[ELF::EI_DATA]; }
532};
533
534template <endianness Endianness>
535struct Elf_Phdr_Impl<ELFType<Endianness, false>> {
536 LLVM_ELF_IMPORT_TYPES(Endianness, false)
537 Elf_Word p_type; // Type of segment
538 Elf_Off p_offset; // FileOffset where segment is located, in bytes
539 Elf_Addr p_vaddr; // Virtual Address of beginning of segment
540 Elf_Addr p_paddr; // Physical address of beginning of segment (OS-specific)
541 Elf_Word p_filesz; // Num. of bytes in file image of segment (may be zero)
542 Elf_Word p_memsz; // Num. of bytes in mem image of segment (may be zero)
543 Elf_Word p_flags; // Segment flags
544 Elf_Word p_align; // Segment alignment constraint
545};
546
547template <endianness Endianness>
548struct Elf_Phdr_Impl<ELFType<Endianness, true>> {
549 LLVM_ELF_IMPORT_TYPES(Endianness, true)
550 Elf_Word p_type; // Type of segment
551 Elf_Word p_flags; // Segment flags
552 Elf_Off p_offset; // FileOffset where segment is located, in bytes
553 Elf_Addr p_vaddr; // Virtual Address of beginning of segment
554 Elf_Addr p_paddr; // Physical address of beginning of segment (OS-specific)
555 Elf_Xword p_filesz; // Num. of bytes in file image of segment (may be zero)
556 Elf_Xword p_memsz; // Num. of bytes in mem image of segment (may be zero)
557 Elf_Xword p_align; // Segment alignment constraint
558};
559
560// ELFT needed for endianness.
561template <class ELFT>
564 Elf_Word nbucket;
565 Elf_Word nchain;
566
567 ArrayRef<Elf_Word> buckets() const {
568 return ArrayRef<Elf_Word>(&nbucket + 2, &nbucket + 2 + nbucket);
569 }
570
572 return ArrayRef<Elf_Word>(&nbucket + 2 + nbucket,
573 &nbucket + 2 + nbucket + nchain);
574 }
575};
576
577// .gnu.hash section
578template <class ELFT>
581 Elf_Word nbuckets;
582 Elf_Word symndx;
583 Elf_Word maskwords;
584 Elf_Word shift2;
585
586 ArrayRef<Elf_Off> filter() const {
587 return ArrayRef<Elf_Off>(reinterpret_cast<const Elf_Off *>(&shift2 + 1),
588 maskwords);
589 }
590
592 return ArrayRef<Elf_Word>(
593 reinterpret_cast<const Elf_Word *>(filter().end()), nbuckets);
594 }
595
596 ArrayRef<Elf_Word> values(unsigned DynamicSymCount) const {
597 assert(DynamicSymCount >= symndx);
598 return ArrayRef<Elf_Word>(buckets().end(), DynamicSymCount - symndx);
599 }
600};
601
602// Compressed section headers.
603// http://www.sco.com/developers/gabi/latest/ch4.sheader.html#compression_header
604template <endianness Endianness>
605struct Elf_Chdr_Impl<ELFType<Endianness, false>> {
606 LLVM_ELF_IMPORT_TYPES(Endianness, false)
607 Elf_Word ch_type;
608 Elf_Word ch_size;
609 Elf_Word ch_addralign;
610};
611
612template <endianness Endianness>
613struct Elf_Chdr_Impl<ELFType<Endianness, true>> {
614 LLVM_ELF_IMPORT_TYPES(Endianness, true)
615 Elf_Word ch_type;
616 Elf_Word ch_reserved;
617 Elf_Xword ch_size;
618 Elf_Xword ch_addralign;
619};
620
621/// Note header
622template <class ELFT>
625 Elf_Word n_namesz;
626 Elf_Word n_descsz;
627 Elf_Word n_type;
628
629 /// Get the size of the note, including name, descriptor, and padding. Both
630 /// the start and the end of the descriptor are aligned by the section
631 /// alignment. In practice many 64-bit systems deviate from the generic ABI by
632 /// using sh_addralign=4.
633 size_t getSize(size_t Align) const {
634 return alignToPowerOf2(sizeof(*this) + n_namesz, Align) +
635 alignToPowerOf2(n_descsz, Align);
636 }
637};
638
639/// An ELF note.
640///
641/// Wraps a note header, providing methods for accessing the name and
642/// descriptor safely.
643template <class ELFT>
646
647 const Elf_Nhdr_Impl<ELFT> &Nhdr;
648
649 template <class NoteIteratorELFT> friend class Elf_Note_Iterator_Impl;
650
651public:
652 Elf_Note_Impl(const Elf_Nhdr_Impl<ELFT> &Nhdr) : Nhdr(Nhdr) {}
653
654 /// Get the note's name, excluding the terminating null byte.
656 if (!Nhdr.n_namesz)
657 return StringRef();
658 return StringRef(reinterpret_cast<const char *>(&Nhdr) + sizeof(Nhdr),
659 Nhdr.n_namesz - 1);
660 }
661
662 /// Get the note's descriptor.
664 if (!Nhdr.n_descsz)
665 return ArrayRef<uint8_t>();
666 return ArrayRef<uint8_t>(
667 reinterpret_cast<const uint8_t *>(&Nhdr) +
668 alignToPowerOf2(sizeof(Nhdr) + Nhdr.n_namesz, Align),
669 Nhdr.n_descsz);
670 }
671
672 /// Get the note's descriptor as StringRef
674 ArrayRef<uint8_t> Desc = getDesc(Align);
675 return StringRef(reinterpret_cast<const char *>(Desc.data()), Desc.size());
676 }
677
678 /// Get the note's type.
679 Elf_Word getType() const { return Nhdr.n_type; }
680};
681
682template <class ELFT> class Elf_Note_Iterator_Impl {
683public:
684 using iterator_category = std::forward_iterator_tag;
686 using difference_type = std::ptrdiff_t;
689
690private:
691 // Nhdr being a nullptr marks the end of iteration.
692 const Elf_Nhdr_Impl<ELFT> *Nhdr = nullptr;
693 size_t RemainingSize = 0u;
694 size_t Align = 0;
695 Error *Err = nullptr;
696
697 template <class ELFFileELFT> friend class ELFFile;
698
699 // Stop iteration and indicate an overflow.
700 void stopWithOverflowError() {
701 Nhdr = nullptr;
702 *Err = make_error<StringError>("ELF note overflows container",
703 object_error::parse_failed);
704 }
705
706 // Advance Nhdr by NoteSize bytes, starting from NhdrPos.
707 //
708 // Assumes NoteSize <= RemainingSize. Ensures Nhdr->getSize() <= RemainingSize
709 // upon returning. Handles stopping iteration when reaching the end of the
710 // container, either cleanly or with an overflow error.
711 void advanceNhdr(const uint8_t *NhdrPos, size_t NoteSize) {
712 RemainingSize -= NoteSize;
713 if (RemainingSize == 0u) {
714 // Ensure that if the iterator walks to the end, the error is checked
715 // afterwards.
716 *Err = Error::success();
717 Nhdr = nullptr;
718 } else if (sizeof(*Nhdr) > RemainingSize)
719 stopWithOverflowError();
720 else {
721 Nhdr = reinterpret_cast<const Elf_Nhdr_Impl<ELFT> *>(NhdrPos + NoteSize);
722 if (Nhdr->getSize(Align) > RemainingSize)
723 stopWithOverflowError();
724 else
725 *Err = Error::success();
726 }
727 }
728
729 Elf_Note_Iterator_Impl() = default;
730 explicit Elf_Note_Iterator_Impl(Error &Err) : Err(&Err) {}
731 Elf_Note_Iterator_Impl(const uint8_t *Start, size_t Size, size_t Align,
732 Error &Err)
733 : RemainingSize(Size), Align(Align), Err(&Err) {
734 consumeError(std::move(Err));
735 assert(Start && "ELF note iterator starting at NULL");
736 advanceNhdr(Start, 0u);
737 }
738
739public:
741 assert(Nhdr && "incremented ELF note end iterator");
742 const uint8_t *NhdrPos = reinterpret_cast<const uint8_t *>(Nhdr);
743 size_t NoteSize = Nhdr->getSize(Align);
744 advanceNhdr(NhdrPos, NoteSize);
745 return *this;
746 }
748 if (!Nhdr && Other.Err)
749 (void)(bool)(*Other.Err);
750 if (!Other.Nhdr && Err)
751 (void)(bool)(*Err);
752 return Nhdr == Other.Nhdr;
753 }
755 return !(*this == Other);
756 }
758 assert(Nhdr && "dereferenced ELF note end iterator");
759 return Elf_Note_Impl<ELFT>(*Nhdr);
760 }
761};
762
763template <class ELFT> struct Elf_CGProfile_Impl {
765 Elf_Xword cgp_weight;
766};
767
768// MIPS .reginfo section
769template <class ELFT>
771
772template <llvm::endianness Endianness>
773struct Elf_Mips_RegInfo<ELFType<Endianness, false>> {
774 LLVM_ELF_IMPORT_TYPES(Endianness, false)
775 Elf_Word ri_gprmask; // bit-mask of used general registers
776 Elf_Word ri_cprmask[4]; // bit-mask of used co-processor registers
777 Elf_Addr ri_gp_value; // gp register value
778};
779
780template <llvm::endianness Endianness>
781struct Elf_Mips_RegInfo<ELFType<Endianness, true>> {
782 LLVM_ELF_IMPORT_TYPES(Endianness, true)
783 Elf_Word ri_gprmask; // bit-mask of used general registers
784 Elf_Word ri_pad; // unused padding field
785 Elf_Word ri_cprmask[4]; // bit-mask of used co-processor registers
786 Elf_Addr ri_gp_value; // gp register value
787};
788
789// .MIPS.options section
790template <class ELFT> struct Elf_Mips_Options {
792 uint8_t kind; // Determines interpretation of variable part of descriptor
793 uint8_t size; // Byte size of descriptor, including this header
794 Elf_Half section; // Section header index of section affected,
795 // or 0 for global options
796 Elf_Word info; // Kind-specific information
797
798 Elf_Mips_RegInfo<ELFT> &getRegInfo() {
799 assert(kind == ELF::ODK_REGINFO);
800 return *reinterpret_cast<Elf_Mips_RegInfo<ELFT> *>(
801 (uint8_t *)this + sizeof(Elf_Mips_Options));
802 }
804 return const_cast<Elf_Mips_Options *>(this)->getRegInfo();
805 }
806};
807
808// .MIPS.abiflags section content
809template <class ELFT> struct Elf_Mips_ABIFlags {
811 Elf_Half version; // Version of the structure
812 uint8_t isa_level; // ISA level: 1-5, 32, and 64
813 uint8_t isa_rev; // ISA revision (0 for MIPS I - MIPS V)
814 uint8_t gpr_size; // General purpose registers size
815 uint8_t cpr1_size; // Co-processor 1 registers size
816 uint8_t cpr2_size; // Co-processor 2 registers size
817 uint8_t fp_abi; // Floating-point ABI flag
818 Elf_Word isa_ext; // Processor-specific extension
819 Elf_Word ases; // ASEs flags
820 Elf_Word flags1; // General flags
821 Elf_Word flags2; // General flags
822};
823
824// Struct representing the BBAddrMap for one function.
825struct BBAddrMap {
826
827 // Bitfield of optional features to control the extra information
828 // emitted/encoded in the the section.
829 struct Features {
831 bool BBFreq : 1;
832 bool BrProb : 1;
833 bool MultiBBRange : 1;
836
837 bool hasPGOAnalysis() const { return FuncEntryCount || BBFreq || BrProb; }
838
839 bool hasPGOAnalysisBBData() const { return BBFreq || BrProb; }
840
841 // Encodes to minimum bit width representation.
842 uint8_t encode() const {
843 return (static_cast<uint8_t>(FuncEntryCount) << 0) |
844 (static_cast<uint8_t>(BBFreq) << 1) |
845 (static_cast<uint8_t>(BrProb) << 2) |
846 (static_cast<uint8_t>(MultiBBRange) << 3) |
847 (static_cast<uint8_t>(OmitBBEntries) << 4) |
848 (static_cast<uint8_t>(CallsiteEndOffsets) << 5);
849 }
850
851 // Decodes from minimum bit width representation and validates no
852 // unnecessary bits are used.
854 Features Feat{
855 static_cast<bool>(Val & (1 << 0)), static_cast<bool>(Val & (1 << 1)),
856 static_cast<bool>(Val & (1 << 2)), static_cast<bool>(Val & (1 << 3)),
857 static_cast<bool>(Val & (1 << 4)), static_cast<bool>(Val & (1 << 5))};
858 if (Feat.encode() != Val)
859 return createStringError(
860 std::error_code(), "invalid encoding for BBAddrMap::Features: 0x%x",
861 Val);
862 return Feat;
863 }
864
865 bool operator==(const Features &Other) const {
866 return std::tie(FuncEntryCount, BBFreq, BrProb, MultiBBRange,
867 OmitBBEntries, CallsiteEndOffsets) ==
868 std::tie(Other.FuncEntryCount, Other.BBFreq, Other.BrProb,
869 Other.MultiBBRange, Other.OmitBBEntries,
870 Other.CallsiteEndOffsets);
871 }
872 };
873
874 // Struct representing the BBAddrMap information for one basic block.
875 struct BBEntry {
876 struct Metadata {
877 bool HasReturn : 1; // If this block ends with a return (or tail
878 // call).
879 bool HasTailCall : 1; // If this block ends with a tail call.
880 bool IsEHPad : 1; // If this is an exception handling block.
881 bool CanFallThrough : 1; // If this block can fall through to its next.
882 bool HasIndirectBranch : 1; // If this block ends with an indirect branch
883 // (branch via a register).
884
885 bool operator==(const Metadata &Other) const {
886 return HasReturn == Other.HasReturn &&
887 HasTailCall == Other.HasTailCall && IsEHPad == Other.IsEHPad &&
888 CanFallThrough == Other.CanFallThrough &&
889 HasIndirectBranch == Other.HasIndirectBranch;
890 }
891
892 // Encodes this struct as a uint32_t value.
893 uint32_t encode() const {
894 return static_cast<uint32_t>(HasReturn) |
895 (static_cast<uint32_t>(HasTailCall) << 1) |
896 (static_cast<uint32_t>(IsEHPad) << 2) |
897 (static_cast<uint32_t>(CanFallThrough) << 3) |
898 (static_cast<uint32_t>(HasIndirectBranch) << 4);
899 }
900
901 // Decodes and returns a Metadata struct from a uint32_t value.
903 Metadata MD{/*HasReturn=*/static_cast<bool>(V & 1),
904 /*HasTailCall=*/static_cast<bool>(V & (1 << 1)),
905 /*IsEHPad=*/static_cast<bool>(V & (1 << 2)),
906 /*CanFallThrough=*/static_cast<bool>(V & (1 << 3)),
907 /*HasIndirectBranch=*/static_cast<bool>(V & (1 << 4))};
908 if (MD.encode() != V)
909 return createStringError(
910 std::error_code(), "invalid encoding for BBEntry::Metadata: 0x%x",
911 V);
912 return MD;
913 }
914 };
915
916 uint32_t ID = 0; // Unique ID of this basic block.
917 uint32_t Offset = 0; // Offset of basic block relative to the base address.
918 uint32_t Size = 0; // Size of the basic block.
919 Metadata MD = {false, false, false, false,
920 false}; // Metdata for this basic block.
921 // Offsets of end of call instructions, relative to the basic block start.
923
925 SmallVector<uint32_t, 1> CallsiteEndOffsets)
926 : ID(ID), Offset(Offset), Size(Size), MD(MD),
927 CallsiteEndOffsets(std::move(CallsiteEndOffsets)) {}
928
929 UniqueBBID getID() const { return {ID, 0}; }
930
931 bool operator==(const BBEntry &Other) const {
932 return ID == Other.ID && Offset == Other.Offset && Size == Other.Size &&
933 MD == Other.MD && CallsiteEndOffsets == Other.CallsiteEndOffsets;
934 }
935
936 bool hasReturn() const { return MD.HasReturn; }
937 bool hasTailCall() const { return MD.HasTailCall; }
938 bool isEHPad() const { return MD.IsEHPad; }
939 bool canFallThrough() const { return MD.CanFallThrough; }
940 bool hasIndirectBranch() const { return MD.HasIndirectBranch; }
941 };
942
943 // Struct representing the BBAddrMap information for a contiguous range of
944 // basic blocks (a function or a basic block section).
946 uint64_t BaseAddress = 0; // Base address of the range.
947 std::vector<BBEntry> BBEntries; // Basic block entries for this range.
948
949 // Equality operator for unit testing.
950 bool operator==(const BBRangeEntry &Other) const {
951 return BaseAddress == Other.BaseAddress &&
952 std::equal(BBEntries.begin(), BBEntries.end(),
953 Other.BBEntries.begin());
954 }
955 };
956
957 // All ranges for this function. Cannot be empty. The first range always
958 // corresponds to the function entry.
959 std::vector<BBRangeEntry> BBRanges;
960
961 // Returns the function address associated with this BBAddrMap, which is
962 // stored as the `BaseAddress` of its first BBRangeEntry.
964 assert(!BBRanges.empty());
965 return BBRanges.front().BaseAddress;
966 }
967
968 // Returns the total number of bb entries in all bb ranges.
969 size_t getNumBBEntries() const {
970 size_t NumBBEntries = 0;
971 for (const auto &BBR : BBRanges)
972 NumBBEntries += BBR.BBEntries.size();
973 return NumBBEntries;
974 }
975
976 // Returns the index of the bb range with the given base address, or
977 // `std::nullopt` if no such range exists.
978 std::optional<size_t>
980 for (size_t I = 0; I < BBRanges.size(); ++I)
981 if (BBRanges[I].BaseAddress == BaseAddress)
982 return I;
983 return {};
984 }
985
986 // Returns bb entries in the first range.
987 const std::vector<BBEntry> &getBBEntries() const {
988 return BBRanges.front().BBEntries;
989 }
990
991 const std::vector<BBRangeEntry> &getBBRanges() const { return BBRanges; }
992
993 // Equality operator for unit testing.
994 bool operator==(const BBAddrMap &Other) const {
995 return std::equal(BBRanges.begin(), BBRanges.end(), Other.BBRanges.begin());
996 }
997};
998
999/// A feature extension of BBAddrMap that holds information relevant to PGO.
1001 /// Extra basic block data with fields for block frequency and branch
1002 /// probability.
1003 struct PGOBBEntry {
1004 /// Single successor of a given basic block that contains the tag and branch
1005 /// probability associated with it.
1007 /// Unique ID of this successor basic block.
1009 /// Branch Probability of the edge to this successor taken from MBPI.
1011
1012 bool operator==(const SuccessorEntry &Other) const {
1013 return std::tie(ID, Prob) == std::tie(Other.ID, Other.Prob);
1014 }
1015 };
1016
1017 /// Block frequency taken from MBFI
1019 /// List of successors of the current block
1021
1022 bool operator==(const PGOBBEntry &Other) const {
1023 return std::tie(BlockFreq, Successors) ==
1024 std::tie(Other.BlockFreq, Other.Successors);
1025 }
1026 };
1027
1028 uint64_t FuncEntryCount; // Prof count from IR function
1029 std::vector<PGOBBEntry> BBEntries; // Extended basic block entries
1030
1031 // Flags to indicate if each PGO related info was enabled in this function
1033
1034 bool operator==(const PGOAnalysisMap &Other) const {
1035 return std::tie(FuncEntryCount, BBEntries, FeatEnable) ==
1036 std::tie(Other.FuncEntryCount, Other.BBEntries, Other.FeatEnable);
1037 }
1038};
1039
1040} // end namespace object.
1041} // end namespace llvm.
1042
1043#endif // LLVM_OBJECT_ELFTYPES_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
aarch64 promote const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool isMips64EL(const ELFYAML::Object &Obj)
uint64_t Align
uint64_t Size
#define LLVM_ELF_IMPORT_TYPES(E, W)
Definition: ELFTypes.h:146
#define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
Definition: ELFTypes.h:107
std::optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1328
uint64_t Offset
Definition: ELF_riscv.cpp:478
lazy value info
#define I(x, y, z)
Definition: MD5.cpp:58
Merge contiguous icmps into a memcmp
Definition: MergeICmps.cpp:915
static StringRef getName(Value *V)
static SymbolRef::Type getType(const Symbol *Sym)
Definition: TapiFile.cpp:39
static unsigned getSize(unsigned Kind)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
Tagged union holding either a T or a Error.
Definition: Error.h:485
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:154
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:148
StringRef getDescAsStringRef(size_t Align) const
Get the note's descriptor as StringRef.
Definition: ELFTypes.h:673
Elf_Word getType() const
Get the note's type.
Definition: ELFTypes.h:679
Elf_Note_Impl(const Elf_Nhdr_Impl< ELFT > &Nhdr)
Definition: ELFTypes.h:652
StringRef getName() const
Get the note's name, excluding the terminating null byte.
Definition: ELFTypes.h:655
ArrayRef< uint8_t > getDesc(size_t Align) const
Get the note's descriptor.
Definition: ELFTypes.h:663
bool operator!=(Elf_Note_Iterator_Impl Other) const
Definition: ELFTypes.h:754
std::forward_iterator_tag iterator_category
Definition: ELFTypes.h:684
Elf_Note_Impl< ELFT > operator*() const
Definition: ELFTypes.h:757
Elf_Note_Iterator_Impl & operator++()
Definition: ELFTypes.h:740
bool operator==(Elf_Note_Iterator_Impl Other) const
Definition: ELFTypes.h:747
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1305
constexpr T alignToPowerOf2(U Value, V Align)
Will overflow only if result is not representable in T.
Definition: MathExtras.h:498
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1886
endianness
Definition: bit.h:71
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1083
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Description of the encoding of one expression Op.
static Expected< Metadata > decode(uint32_t V)
Definition: ELFTypes.h:902
bool operator==(const Metadata &Other) const
Definition: ELFTypes.h:885
SmallVector< uint32_t, 1 > CallsiteEndOffsets
Definition: ELFTypes.h:922
BBEntry(uint32_t ID, uint32_t Offset, uint32_t Size, Metadata MD, SmallVector< uint32_t, 1 > CallsiteEndOffsets)
Definition: ELFTypes.h:924
bool operator==(const BBEntry &Other) const
Definition: ELFTypes.h:931
UniqueBBID getID() const
Definition: ELFTypes.h:929
bool operator==(const BBRangeEntry &Other) const
Definition: ELFTypes.h:950
std::vector< BBEntry > BBEntries
Definition: ELFTypes.h:947
bool operator==(const Features &Other) const
Definition: ELFTypes.h:865
static Expected< Features > decode(uint8_t Val)
Definition: ELFTypes.h:853
const std::vector< BBRangeEntry > & getBBRanges() const
Definition: ELFTypes.h:991
std::vector< BBRangeEntry > BBRanges
Definition: ELFTypes.h:959
size_t getNumBBEntries() const
Definition: ELFTypes.h:969
bool operator==(const BBAddrMap &Other) const
Definition: ELFTypes.h:994
const std::vector< BBEntry > & getBBEntries() const
Definition: ELFTypes.h:987
uint64_t getFunctionAddress() const
Definition: ELFTypes.h:963
std::optional< size_t > getBBRangeIndexForBaseAddress(uint64_t BaseAddress) const
Definition: ELFTypes.h:979
std::conditional_t< Is64, uint64_t, uint32_t > uint
Definition: ELFTypes.h:59
static const endianness Endianness
Definition: ELFTypes.h:56
static const bool Is64Bits
Definition: ELFTypes.h:57
uint32_t getType(bool) const
Definition: ELFTypes.h:499
std::conditional_t< Is64, uint64_t, uint32_t > uint
Definition: ELFTypes.h:490
uint32_t getSymbol(bool) const
Definition: ELFTypes.h:500
void setSymbolAndType(uint32_t s, unsigned char t, bool)
Definition: ELFTypes.h:501
std::conditional_t< Is64, int64_t, int32_t > r_addend
Definition: ELFTypes.h:496
Elf_Dyn_Base: This structure matches the form of entries in the dynamic table section (....
Definition: ELFTypes.h:354
Elf_Dyn_Impl: This inherits from Elf_Dyn_Base, adding getters.
Definition: ELFTypes.h:378
uintX_t getVal() const
Definition: ELFTypes.h:384
std::conditional_t< ELFT::Is64Bits, int64_t, int32_t > intX_t
Definition: ELFTypes.h:381
std::conditional_t< ELFT::Is64Bits, uint64_t, uint32_t > uintX_t
Definition: ELFTypes.h:382
uintX_t getPtr() const
Definition: ELFTypes.h:385
intX_t getTag() const
Definition: ELFTypes.h:383
unsigned char getFileClass() const
Definition: ELFTypes.h:530
unsigned char getDataEncoding() const
Definition: ELFTypes.h:531
ArrayRef< Elf_Word > values(unsigned DynamicSymCount) const
Definition: ELFTypes.h:596
ArrayRef< Elf_Word > buckets() const
Definition: ELFTypes.h:591
ArrayRef< Elf_Word > chains() const
Definition: ELFTypes.h:571
const Elf_Mips_RegInfo< ELFT > & getRegInfo() const
Definition: ELFTypes.h:803
size_t getSize(size_t Align) const
Get the size of the note, including name, descriptor, and padding.
Definition: ELFTypes.h:633
void setSymbolAndType(uint32_t s, unsigned char t, bool IsMips64EL)
Definition: ELFTypes.h:419
void setSymbolAndType(uint32_t s, uint32_t t, bool IsMips64EL)
Definition: ELFTypes.h:474
unsigned getEntityCount() const
Get the number of entities this section contains if it has any.
Definition: ELFTypes.h:188
void setBindingAndType(unsigned char b, unsigned char t)
Definition: ELFTypes.h:234
bool isProcessorSpecific() const
Definition: ELFTypes.h:257
void setBinding(unsigned char b)
Definition: ELFTypes.h:231
unsigned char getBinding() const
Definition: ELFTypes.h:228
bool isDefined() const
Definition: ELFTypes.h:255
bool isAbsolute() const
Definition: ELFTypes.h:249
bool isOSSpecific() const
Definition: ELFTypes.h:261
unsigned char getType() const
Definition: ELFTypes.h:229
uint64_t getValue() const
Definition: ELFTypes.h:230
void setVisibility(unsigned char v)
Definition: ELFTypes.h:244
bool isExternal() const
Definition: ELFTypes.h:273
void setType(unsigned char t)
Definition: ELFTypes.h:232
bool isUndefined() const
Definition: ELFTypes.h:271
bool isReserved() const
Definition: ELFTypes.h:265
unsigned char getVisibility() const
Access to the STV_xxx flag stored in the first two bits of st_other.
Definition: ELFTypes.h:243
Elf_Verdaux: This is the structure of auxiliary data in the SHT_GNU_verdef section (....
Definition: ELFTypes.h:322
Elf_Verdef: This is the structure of entries in the SHT_GNU_verdef section (.gnu.version_d).
Definition: ELFTypes.h:303
Elf_Vernaux: This is the structure of auxiliary data in SHT_GNU_verneed section (....
Definition: ELFTypes.h:343
Elf_Verneed: This is the structure of entries in the SHT_GNU_verneed section (.gnu....
Definition: ELFTypes.h:331
Elf_Versym: This is the structure of entries in the SHT_GNU_versym section (.gnu.version).
Definition: ELFTypes.h:295
Single successor of a given basic block that contains the tag and branch probability associated with ...
Definition: ELFTypes.h:1006
uint32_t ID
Unique ID of this successor basic block.
Definition: ELFTypes.h:1008
BranchProbability Prob
Branch Probability of the edge to this successor taken from MBPI.
Definition: ELFTypes.h:1010
bool operator==(const SuccessorEntry &Other) const
Definition: ELFTypes.h:1012
Extra basic block data with fields for block frequency and branch probability.
Definition: ELFTypes.h:1003
bool operator==(const PGOBBEntry &Other) const
Definition: ELFTypes.h:1022
llvm::SmallVector< SuccessorEntry, 2 > Successors
List of successors of the current block.
Definition: ELFTypes.h:1020
BlockFrequency BlockFreq
Block frequency taken from MBFI.
Definition: ELFTypes.h:1018
A feature extension of BBAddrMap that holds information relevant to PGO.
Definition: ELFTypes.h:1000
bool operator==(const PGOAnalysisMap &Other) const
Definition: ELFTypes.h:1034
std::vector< PGOBBEntry > BBEntries
Definition: ELFTypes.h:1029
BBAddrMap::Features FeatEnable
Definition: ELFTypes.h:1032