LLVM 20.0.0git
ELFYAML.h
Go to the documentation of this file.
1//===- ELFYAML.h - ELF YAMLIO implementation --------------------*- 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/// \file
10/// This file declares classes for handling the YAML representation
11/// of ELF.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_OBJECTYAML_ELFYAML_H
16#define LLVM_OBJECTYAML_ELFYAML_H
17
18#include "llvm/ADT/StringRef.h"
24#include <cstdint>
25#include <memory>
26#include <optional>
27#include <vector>
28
29namespace llvm {
30namespace ELFYAML {
31
33std::string appendUniqueSuffix(StringRef Name, const Twine& Msg);
34
35// These types are invariant across 32/64-bit ELF, so for simplicity just
36// directly give them their exact sizes. We don't need to worry about
37// endianness because these are just the types in the YAMLIO structures,
38// and are appropriately converted to the necessary endianness when
39// reading/generating binary object files.
40// The naming of these types is intended to be ELF_PREFIX, where PREFIX is
41// the common prefix of the respective constants. E.g. ELF_EM corresponds
42// to the `e_machine` constants, like `EM_X86_64`.
43// In the future, these would probably be better suited by C++11 enum
44// class's with appropriate fixed underlying type.
51// Just use 64, since it can hold 32-bit values too.
53// Just use 64, since it can hold 32-bit values too.
59// Just use 64, since it can hold 32-bit values too.
65
70LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_FLAGS1)
72
74LLVM_YAML_STRONG_TYPEDEF(int64_t, YAMLIntUInt)
75
76template <class ELFT>
77unsigned getDefaultShEntSize(unsigned EMachine, ELF_SHT SecType,
78 StringRef SecName) {
79 if (EMachine == ELF::EM_MIPS && SecType == ELF::SHT_MIPS_ABIFLAGS)
81
82 switch (SecType) {
83 case ELF::SHT_SYMTAB:
84 case ELF::SHT_DYNSYM:
85 return sizeof(typename ELFT::Sym);
86 case ELF::SHT_GROUP:
87 return sizeof(typename ELFT::Word);
88 case ELF::SHT_REL:
89 return sizeof(typename ELFT::Rel);
90 case ELF::SHT_RELA:
91 return sizeof(typename ELFT::Rela);
92 case ELF::SHT_RELR:
93 return sizeof(typename ELFT::Relr);
95 return sizeof(typename ELFT::Dyn);
96 case ELF::SHT_HASH:
97 return sizeof(typename ELFT::Word);
99 return sizeof(typename ELFT::Word);
101 return sizeof(typename ELFT::Half);
104 default:
105 if (SecName == ".debug_str")
106 return 1;
107 return 0;
108 }
109}
110
111// For now, hardcode 64 bits everywhere that 32 or 64 would be needed
112// since 64-bit can hold 32-bit values too.
114 ELF_ELFCLASS Class;
115 ELF_ELFDATA Data;
116 ELF_ELFOSABI OSABI;
117 llvm::yaml::Hex8 ABIVersion;
118 ELF_ET Type;
119 std::optional<ELF_EM> Machine;
120 ELF_EF Flags;
121 llvm::yaml::Hex64 Entry;
122 std::optional<StringRef> SectionHeaderStringTable;
123
124 std::optional<llvm::yaml::Hex64> EPhOff;
125 std::optional<llvm::yaml::Hex16> EPhEntSize;
126 std::optional<llvm::yaml::Hex16> EPhNum;
127 std::optional<llvm::yaml::Hex16> EShEntSize;
128 std::optional<llvm::yaml::Hex64> EShOff;
129 std::optional<llvm::yaml::Hex16> EShNum;
130 std::optional<llvm::yaml::Hex16> EShStrNdx;
131};
132
135};
136
137struct Symbol {
139 ELF_STT Type;
140 std::optional<StringRef> Section;
141 std::optional<ELF_SHN> Index;
142 ELF_STB Binding;
143 std::optional<llvm::yaml::Hex64> Value;
144 std::optional<llvm::yaml::Hex64> Size;
145 std::optional<uint8_t> Other;
146
147 std::optional<uint32_t> StName;
148};
149
152};
153
155 ELF_DYNTAG Tag;
156 llvm::yaml::Hex64 Val;
157};
158
160 struct BBEntry {
162 llvm::yaml::Hex64 AddressOffset;
163 llvm::yaml::Hex64 Size;
164 llvm::yaml::Hex64 Metadata;
165 };
167 llvm::yaml::Hex8 Feature;
168
170 llvm::yaml::Hex64 BaseAddress;
171 std::optional<uint64_t> NumBlocks;
172 std::optional<std::vector<BBEntry>> BBEntries;
173 };
174
175 std::optional<uint64_t> NumBBRanges;
176 std::optional<std::vector<BBRangeEntry>> BBRanges;
177
178 llvm::yaml::Hex64 getFunctionAddress() const {
179 if (!BBRanges || BBRanges->empty())
180 return 0;
181 return BBRanges->front().BaseAddress;
182 }
183};
184
186 struct PGOBBEntry {
189 llvm::yaml::Hex32 BrProb;
190 };
191 std::optional<uint64_t> BBFreq;
192 std::optional<std::vector<SuccessorEntry>> Successors;
193 };
194 std::optional<uint64_t> FuncEntryCount;
195 std::optional<std::vector<PGOBBEntry>> PGOBBEntries;
196};
197
199 llvm::yaml::Hex64 Address;
200 llvm::yaml::Hex64 Size;
201};
202
203struct NoteEntry {
206 ELF_NT Type;
207};
208
209struct Chunk {
210 enum class ChunkKind {
211 Dynamic,
212 Group,
215 Relr,
216 NoBits,
217 Note,
218 Hash,
219 GnuHash,
220 Verdef,
221 Verneed,
224 Symver,
227 Addrsig,
231 BBAddrMap,
232
233 // Special chunks.
237 };
238
241 std::optional<llvm::yaml::Hex64> Offset;
242
243 // Usually chunks are not created implicitly, but rather loaded from YAML.
244 // This flag is used to signal whether this is the case or not.
246
247 Chunk(ChunkKind K, bool Implicit) : Kind(K), IsImplicit(Implicit) {}
248 virtual ~Chunk();
249};
250
251struct Section : public Chunk {
252 ELF_SHT Type;
253 std::optional<ELF_SHF> Flags;
254 std::optional<llvm::yaml::Hex64> Address;
255 std::optional<StringRef> Link;
256 llvm::yaml::Hex64 AddressAlign;
257 std::optional<llvm::yaml::Hex64> EntSize;
258
259 std::optional<yaml::BinaryRef> Content;
260 std::optional<llvm::yaml::Hex64> Size;
261
262 // Holds the original section index.
264
266
267 static bool classof(const Chunk *S) {
269 }
270
271 // Some derived sections might have their own special entries. This method
272 // returns a vector of <entry name, is used> pairs. It is used for section
273 // validation.
274 virtual std::vector<std::pair<StringRef, bool>> getEntries() const {
275 return {};
276 };
277
278 // The following members are used to override section fields which is
279 // useful for creating invalid objects.
280
281 // This can be used to override the sh_addralign field.
282 std::optional<llvm::yaml::Hex64> ShAddrAlign;
283
284 // This can be used to override the offset stored in the sh_name field.
285 // It does not affect the name stored in the string table.
286 std::optional<llvm::yaml::Hex64> ShName;
287
288 // This can be used to override the sh_offset field. It does not place the
289 // section data at the offset specified.
290 std::optional<llvm::yaml::Hex64> ShOffset;
291
292 // This can be used to override the sh_size field. It does not affect the
293 // content written.
294 std::optional<llvm::yaml::Hex64> ShSize;
295
296 // This can be used to override the sh_flags field.
297 std::optional<llvm::yaml::Hex64> ShFlags;
298
299 // This can be used to override the sh_type field. It is useful when we
300 // want to use specific YAML keys for a section of a particular type to
301 // describe the content, but still want to have a different final type
302 // for the section.
303 std::optional<ELF_SHT> ShType;
304};
305
306// Fill is a block of data which is placed outside of sections. It is
307// not present in the sections header table, but it might affect the output file
308// size and program headers produced.
309struct Fill : Chunk {
310 std::optional<yaml::BinaryRef> Pattern;
311 llvm::yaml::Hex64 Size;
312
313 Fill() : Chunk(ChunkKind::Fill, /*Implicit=*/false) {}
314
315 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Fill; }
316};
317
321
322 static bool classof(const Chunk *S) {
324 }
325
326 std::optional<std::vector<SectionHeader>> Sections;
327 std::optional<std::vector<SectionHeader>> Excluded;
328 std::optional<bool> NoHeaders;
329
330 size_t getNumHeaders(size_t SectionsNum) const {
331 if (IsImplicit || isDefault())
332 return SectionsNum;
333 if (NoHeaders)
334 return (*NoHeaders) ? 0 : SectionsNum;
335 return (Sections ? Sections->size() : 0) + /*Null section*/ 1;
336 }
337
338 bool isDefault() const { return !Sections && !Excluded && !NoHeaders; }
339
340 static constexpr StringRef TypeStr = "SectionHeaderTable";
341};
342
344 std::optional<std::vector<BBAddrMapEntry>> Entries;
345 std::optional<std::vector<PGOAnalysisMapEntry>> PGOAnalyses;
346
348
349 std::vector<std::pair<StringRef, bool>> getEntries() const override {
350 return {{"Entries", Entries.has_value()}};
351 };
352
353 static bool classof(const Chunk *S) {
354 return S->Kind == ChunkKind::BBAddrMap;
355 }
356};
357
359 std::optional<std::vector<StackSizeEntry>> Entries;
360
362
363 std::vector<std::pair<StringRef, bool>> getEntries() const override {
364 return {{"Entries", Entries.has_value()}};
365 };
366
367 static bool classof(const Chunk *S) {
368 return S->Kind == ChunkKind::StackSizes;
369 }
370
372 return Name == ".stack_sizes";
373 }
374};
375
377 std::optional<std::vector<DynamicEntry>> Entries;
378
380
381 std::vector<std::pair<StringRef, bool>> getEntries() const override {
382 return {{"Entries", Entries.has_value()}};
383 };
384
385 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Dynamic; }
386};
387
389 std::optional<llvm::yaml::Hex64> Info;
390
392
393 static bool classof(const Chunk *S) {
394 return S->Kind == ChunkKind::RawContent;
395 }
396
397 // Is used when a content is read as an array of bytes.
398 std::optional<std::vector<uint8_t>> ContentBuf;
399};
400
403
404 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::NoBits; }
405};
406
408 std::optional<std::vector<ELFYAML::NoteEntry>> Notes;
409
411
412 std::vector<std::pair<StringRef, bool>> getEntries() const override {
413 return {{"Notes", Notes.has_value()}};
414 };
415
416 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Note; }
417};
418
420 std::optional<std::vector<uint32_t>> Bucket;
421 std::optional<std::vector<uint32_t>> Chain;
422
423 std::vector<std::pair<StringRef, bool>> getEntries() const override {
424 return {{"Bucket", Bucket.has_value()}, {"Chain", Chain.has_value()}};
425 };
426
427 // The following members are used to override section fields.
428 // This is useful for creating invalid objects.
429 std::optional<llvm::yaml::Hex64> NBucket;
430 std::optional<llvm::yaml::Hex64> NChain;
431
433
434 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Hash; }
435};
436
438 // The number of hash buckets.
439 // Not used when dumping the object, but can be used to override
440 // the real number of buckets when emiting an object from a YAML document.
441 std::optional<llvm::yaml::Hex32> NBuckets;
442
443 // Index of the first symbol in the dynamic symbol table
444 // included in the hash table.
445 llvm::yaml::Hex32 SymNdx;
446
447 // The number of words in the Bloom filter.
448 // Not used when dumping the object, but can be used to override the real
449 // number of words in the Bloom filter when emiting an object from a YAML
450 // document.
451 std::optional<llvm::yaml::Hex32> MaskWords;
452
453 // A shift constant used by the Bloom filter.
454 llvm::yaml::Hex32 Shift2;
455};
456
458 std::optional<GnuHashHeader> Header;
459 std::optional<std::vector<llvm::yaml::Hex64>> BloomFilter;
460 std::optional<std::vector<llvm::yaml::Hex32>> HashBuckets;
461 std::optional<std::vector<llvm::yaml::Hex32>> HashValues;
462
464
465 std::vector<std::pair<StringRef, bool>> getEntries() const override {
466 return {{"Header", Header.has_value()},
467 {"BloomFilter", BloomFilter.has_value()},
468 {"HashBuckets", HashBuckets.has_value()},
469 {"HashValues", HashValues.has_value()}};
470 };
471
472 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::GnuHash; }
473};
474
480};
481
485 std::vector<VernauxEntry> AuxV;
486};
487
489 std::optional<std::vector<VerneedEntry>> VerneedV;
490 std::optional<llvm::yaml::Hex64> Info;
491
493
494 std::vector<std::pair<StringRef, bool>> getEntries() const override {
495 return {{"Dependencies", VerneedV.has_value()}};
496 };
497
498 static bool classof(const Chunk *S) {
499 return S->Kind == ChunkKind::Verneed;
500 }
501};
502
504 std::optional<std::vector<YAMLFlowString>> Symbols;
505
507
508 std::vector<std::pair<StringRef, bool>> getEntries() const override {
509 return {{"Symbols", Symbols.has_value()}};
510 };
511
512 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Addrsig; }
513};
514
518};
519
521 std::optional<std::vector<LinkerOption>> Options;
522
524
525 std::vector<std::pair<StringRef, bool>> getEntries() const override {
526 return {{"Options", Options.has_value()}};
527 };
528
529 static bool classof(const Chunk *S) {
530 return S->Kind == ChunkKind::LinkerOptions;
531 }
532};
533
535 std::optional<std::vector<YAMLFlowString>> Libs;
536
538
539 std::vector<std::pair<StringRef, bool>> getEntries() const override {
540 return {{"Libraries", Libs.has_value()}};
541 };
542
543 static bool classof(const Chunk *S) {
545 }
546};
547
548// Represents the call graph profile section entry.
550 // The weight of the edge.
552};
553
555 std::optional<std::vector<CallGraphEntryWeight>> Entries;
556
558
559 std::vector<std::pair<StringRef, bool>> getEntries() const override {
560 return {{"Entries", Entries.has_value()}};
561 };
562
563 static bool classof(const Chunk *S) {
565 }
566};
567
569 std::optional<std::vector<uint16_t>> Entries;
570
572
573 std::vector<std::pair<StringRef, bool>> getEntries() const override {
574 return {{"Entries", Entries.has_value()}};
575 };
576
577 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Symver; }
578};
579
581 std::optional<uint16_t> Version;
582 std::optional<uint16_t> Flags;
583 std::optional<uint16_t> VersionNdx;
584 std::optional<uint32_t> Hash;
585 std::optional<uint16_t> VDAux;
586 std::vector<StringRef> VerNames;
587};
588
590 std::optional<std::vector<VerdefEntry>> Entries;
591 std::optional<llvm::yaml::Hex64> Info;
592
594
595 std::vector<std::pair<StringRef, bool>> getEntries() const override {
596 return {{"Entries", Entries.has_value()}};
597 };
598
599 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Verdef; }
600};
601
603 // Members of a group contain a flag and a list of section indices
604 // that are part of the group.
605 std::optional<std::vector<SectionOrType>> Members;
606 std::optional<StringRef> Signature; /* Info */
607
609
610 std::vector<std::pair<StringRef, bool>> getEntries() const override {
611 return {{"Members", Members.has_value()}};
612 };
613
614 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Group; }
615};
616
618 llvm::yaml::Hex64 Offset;
619 YAMLIntUInt Addend;
620 ELF_REL Type;
621 std::optional<StringRef> Symbol;
622};
623
625 std::optional<std::vector<Relocation>> Relocations;
627
629
630 std::vector<std::pair<StringRef, bool>> getEntries() const override {
631 return {{"Relocations", Relocations.has_value()}};
632 };
633
634 static bool classof(const Chunk *S) {
635 return S->Kind == ChunkKind::Relocation;
636 }
637};
638
640 std::optional<std::vector<llvm::yaml::Hex64>> Entries;
641
643
644 std::vector<std::pair<StringRef, bool>> getEntries() const override {
645 return {{"Entries", Entries.has_value()}};
646 };
647
648 static bool classof(const Chunk *S) {
649 return S->Kind == ChunkKind::Relr;
650 }
651};
652
654 std::optional<std::vector<uint32_t>> Entries;
655
657
658 std::vector<std::pair<StringRef, bool>> getEntries() const override {
659 return {{"Entries", Entries.has_value()}};
660 };
661
662 static bool classof(const Chunk *S) {
664 }
665};
666
668 llvm::yaml::Hex32 Offset;
669 llvm::yaml::Hex32 Value;
670};
671
673 std::optional<std::vector<ARMIndexTableEntry>> Entries;
674
676
677 std::vector<std::pair<StringRef, bool>> getEntries() const override {
678 return {{"Entries", Entries.has_value()}};
679 };
680
681 static bool classof(const Chunk *S) {
682 return S->Kind == ChunkKind::ARMIndexTable;
683 }
684};
685
686// Represents .MIPS.abiflags section
688 llvm::yaml::Hex16 Version;
689 MIPS_ISA ISALevel;
690 llvm::yaml::Hex8 ISARevision;
691 MIPS_AFL_REG GPRSize;
692 MIPS_AFL_REG CPR1Size;
693 MIPS_AFL_REG CPR2Size;
694 MIPS_ABI_FP FpABI;
695 MIPS_AFL_EXT ISAExtension;
696 MIPS_AFL_ASE ASEs;
697 MIPS_AFL_FLAGS1 Flags1;
698 llvm::yaml::Hex32 Flags2;
699
701
702 static bool classof(const Chunk *S) {
703 return S->Kind == ChunkKind::MipsABIFlags;
704 }
705};
706
708 ELF_PT Type;
709 ELF_PF Flags;
710 llvm::yaml::Hex64 VAddr;
711 llvm::yaml::Hex64 PAddr;
712 std::optional<llvm::yaml::Hex64> Align;
713 std::optional<llvm::yaml::Hex64> FileSize;
714 std::optional<llvm::yaml::Hex64> MemSize;
715 std::optional<llvm::yaml::Hex64> Offset;
716 std::optional<StringRef> FirstSec;
717 std::optional<StringRef> LastSec;
718
719 // This vector contains all chunks from [FirstSec, LastSec].
720 std::vector<Chunk *> Chunks;
721};
722
723struct Object {
725 std::vector<ProgramHeader> ProgramHeaders;
726
727 // An object might contain output section descriptions as well as
728 // custom data that does not belong to any section.
729 std::vector<std::unique_ptr<Chunk>> Chunks;
730
731 // Although in reality the symbols reside in a section, it is a lot
732 // cleaner and nicer if we read them from the YAML as a separate
733 // top-level key, which automatically ensures that invariants like there
734 // being a single SHT_SYMTAB section are upheld.
735 std::optional<std::vector<Symbol>> Symbols;
736 std::optional<std::vector<Symbol>> DynamicSymbols;
737 std::optional<DWARFYAML::Data> DWARF;
738
739 std::vector<Section *> getSections() {
740 std::vector<Section *> Ret;
741 for (const std::unique_ptr<Chunk> &Sec : Chunks)
742 if (auto S = dyn_cast<ELFYAML::Section>(Sec.get()))
743 Ret.push_back(S);
744 return Ret;
745 }
746
748 for (const std::unique_ptr<Chunk> &C : Chunks)
749 if (auto *S = dyn_cast<ELFYAML::SectionHeaderTable>(C.get()))
750 return *S;
751 llvm_unreachable("the section header table chunk must always be present");
752 }
753
754 ELF_ELFOSABI getOSAbi() const;
755 unsigned getMachine() const;
756};
757
759 const NoBitsSection &S);
760
761} // end namespace ELFYAML
762} // end namespace llvm
763
771 llvm::ELFYAML::PGOAnalysisMapEntry::PGOBBEntry::SuccessorEntry)
772LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::DynamicEntry)
773LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::LinkerOption)
774LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::CallGraphEntryWeight)
775LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::NoteEntry)
776LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::ProgramHeader)
777LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::SectionHeader)
778LLVM_YAML_IS_SEQUENCE_VECTOR(std::unique_ptr<llvm::ELFYAML::Chunk>)
779LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::Symbol)
780LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::VerdefEntry)
781LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::VernauxEntry)
782LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::VerneedEntry)
783LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::Relocation)
784LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::SectionOrType)
785LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::ARMIndexTableEntry)
786
787namespace llvm {
788namespace yaml {
789
790template <> struct ScalarTraits<ELFYAML::YAMLIntUInt> {
791 static void output(const ELFYAML::YAMLIntUInt &Val, void *Ctx,
792 raw_ostream &Out);
793 static StringRef input(StringRef Scalar, void *Ctx,
794 ELFYAML::YAMLIntUInt &Val);
795 static QuotingType mustQuote(StringRef) { return QuotingType::None; }
796};
797
798template <>
799struct ScalarEnumerationTraits<ELFYAML::ELF_ET> {
800 static void enumeration(IO &IO, ELFYAML::ELF_ET &Value);
801};
802
803template <> struct ScalarEnumerationTraits<ELFYAML::ELF_PT> {
804 static void enumeration(IO &IO, ELFYAML::ELF_PT &Value);
805};
806
807template <> struct ScalarEnumerationTraits<ELFYAML::ELF_NT> {
808 static void enumeration(IO &IO, ELFYAML::ELF_NT &Value);
809};
810
811template <>
812struct ScalarEnumerationTraits<ELFYAML::ELF_EM> {
813 static void enumeration(IO &IO, ELFYAML::ELF_EM &Value);
814};
815
816template <>
817struct ScalarEnumerationTraits<ELFYAML::ELF_ELFCLASS> {
818 static void enumeration(IO &IO, ELFYAML::ELF_ELFCLASS &Value);
819};
820
821template <>
822struct ScalarEnumerationTraits<ELFYAML::ELF_ELFDATA> {
823 static void enumeration(IO &IO, ELFYAML::ELF_ELFDATA &Value);
824};
825
826template <>
827struct ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI> {
828 static void enumeration(IO &IO, ELFYAML::ELF_ELFOSABI &Value);
829};
830
831template <>
832struct ScalarBitSetTraits<ELFYAML::ELF_EF> {
833 static void bitset(IO &IO, ELFYAML::ELF_EF &Value);
834};
835
836template <> struct ScalarBitSetTraits<ELFYAML::ELF_PF> {
837 static void bitset(IO &IO, ELFYAML::ELF_PF &Value);
838};
839
840template <>
841struct ScalarEnumerationTraits<ELFYAML::ELF_SHT> {
842 static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value);
843};
844
845template <>
846struct ScalarBitSetTraits<ELFYAML::ELF_SHF> {
847 static void bitset(IO &IO, ELFYAML::ELF_SHF &Value);
848};
849
850template <> struct ScalarEnumerationTraits<ELFYAML::ELF_SHN> {
851 static void enumeration(IO &IO, ELFYAML::ELF_SHN &Value);
852};
853
854template <> struct ScalarEnumerationTraits<ELFYAML::ELF_STB> {
855 static void enumeration(IO &IO, ELFYAML::ELF_STB &Value);
856};
857
858template <>
859struct ScalarEnumerationTraits<ELFYAML::ELF_STT> {
860 static void enumeration(IO &IO, ELFYAML::ELF_STT &Value);
861};
862
863template <>
864struct ScalarEnumerationTraits<ELFYAML::ELF_REL> {
865 static void enumeration(IO &IO, ELFYAML::ELF_REL &Value);
866};
867
868template <>
869struct ScalarEnumerationTraits<ELFYAML::ELF_DYNTAG> {
870 static void enumeration(IO &IO, ELFYAML::ELF_DYNTAG &Value);
871};
872
873template <>
874struct ScalarEnumerationTraits<ELFYAML::ELF_RSS> {
875 static void enumeration(IO &IO, ELFYAML::ELF_RSS &Value);
876};
877
878template <>
879struct ScalarEnumerationTraits<ELFYAML::MIPS_AFL_REG> {
880 static void enumeration(IO &IO, ELFYAML::MIPS_AFL_REG &Value);
881};
882
883template <>
884struct ScalarEnumerationTraits<ELFYAML::MIPS_ABI_FP> {
885 static void enumeration(IO &IO, ELFYAML::MIPS_ABI_FP &Value);
886};
887
888template <>
889struct ScalarEnumerationTraits<ELFYAML::MIPS_AFL_EXT> {
890 static void enumeration(IO &IO, ELFYAML::MIPS_AFL_EXT &Value);
891};
892
893template <>
894struct ScalarEnumerationTraits<ELFYAML::MIPS_ISA> {
895 static void enumeration(IO &IO, ELFYAML::MIPS_ISA &Value);
896};
897
898template <>
899struct ScalarBitSetTraits<ELFYAML::MIPS_AFL_ASE> {
900 static void bitset(IO &IO, ELFYAML::MIPS_AFL_ASE &Value);
901};
902
903template <>
904struct ScalarBitSetTraits<ELFYAML::MIPS_AFL_FLAGS1> {
905 static void bitset(IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value);
906};
907
908template <>
909struct MappingTraits<ELFYAML::FileHeader> {
910 static void mapping(IO &IO, ELFYAML::FileHeader &FileHdr);
911};
912
913template <> struct MappingTraits<ELFYAML::SectionHeader> {
914 static void mapping(IO &IO, ELFYAML::SectionHeader &SHdr);
915};
916
917template <> struct MappingTraits<ELFYAML::ProgramHeader> {
918 static void mapping(IO &IO, ELFYAML::ProgramHeader &FileHdr);
919 static std::string validate(IO &IO, ELFYAML::ProgramHeader &FileHdr);
920};
921
922template <>
923struct MappingTraits<ELFYAML::Symbol> {
924 static void mapping(IO &IO, ELFYAML::Symbol &Symbol);
925 static std::string validate(IO &IO, ELFYAML::Symbol &Symbol);
926};
927
928template <> struct MappingTraits<ELFYAML::StackSizeEntry> {
929 static void mapping(IO &IO, ELFYAML::StackSizeEntry &Rel);
930};
931
932template <> struct MappingTraits<ELFYAML::BBAddrMapEntry> {
933 static void mapping(IO &IO, ELFYAML::BBAddrMapEntry &E);
934};
935
936template <> struct MappingTraits<ELFYAML::BBAddrMapEntry::BBRangeEntry> {
937 static void mapping(IO &IO, ELFYAML::BBAddrMapEntry::BBRangeEntry &E);
938};
939
940template <> struct MappingTraits<ELFYAML::BBAddrMapEntry::BBEntry> {
941 static void mapping(IO &IO, ELFYAML::BBAddrMapEntry::BBEntry &E);
942};
943
944template <> struct MappingTraits<ELFYAML::PGOAnalysisMapEntry> {
945 static void mapping(IO &IO, ELFYAML::PGOAnalysisMapEntry &Rel);
946};
947
948template <> struct MappingTraits<ELFYAML::PGOAnalysisMapEntry::PGOBBEntry> {
949 static void mapping(IO &IO, ELFYAML::PGOAnalysisMapEntry::PGOBBEntry &Rel);
950};
951
952template <>
953struct MappingTraits<ELFYAML::PGOAnalysisMapEntry::PGOBBEntry::SuccessorEntry> {
954 static void
955 mapping(IO &IO,
956 ELFYAML::PGOAnalysisMapEntry::PGOBBEntry::SuccessorEntry &Rel);
957};
958
959template <> struct MappingTraits<ELFYAML::GnuHashHeader> {
960 static void mapping(IO &IO, ELFYAML::GnuHashHeader &Rel);
961};
962
963template <> struct MappingTraits<ELFYAML::DynamicEntry> {
964 static void mapping(IO &IO, ELFYAML::DynamicEntry &Rel);
965};
966
967template <> struct MappingTraits<ELFYAML::NoteEntry> {
968 static void mapping(IO &IO, ELFYAML::NoteEntry &N);
969};
970
971template <> struct MappingTraits<ELFYAML::VerdefEntry> {
972 static void mapping(IO &IO, ELFYAML::VerdefEntry &E);
973};
974
975template <> struct MappingTraits<ELFYAML::VerneedEntry> {
976 static void mapping(IO &IO, ELFYAML::VerneedEntry &E);
977};
978
979template <> struct MappingTraits<ELFYAML::VernauxEntry> {
980 static void mapping(IO &IO, ELFYAML::VernauxEntry &E);
981};
982
983template <> struct MappingTraits<ELFYAML::LinkerOption> {
984 static void mapping(IO &IO, ELFYAML::LinkerOption &Sym);
985};
986
987template <> struct MappingTraits<ELFYAML::CallGraphEntryWeight> {
988 static void mapping(IO &IO, ELFYAML::CallGraphEntryWeight &E);
989};
990
991template <> struct MappingTraits<ELFYAML::Relocation> {
992 static void mapping(IO &IO, ELFYAML::Relocation &Rel);
993};
994
995template <> struct MappingTraits<ELFYAML::ARMIndexTableEntry> {
996 static void mapping(IO &IO, ELFYAML::ARMIndexTableEntry &E);
997};
998
999template <> struct MappingTraits<std::unique_ptr<ELFYAML::Chunk>> {
1000 static void mapping(IO &IO, std::unique_ptr<ELFYAML::Chunk> &C);
1001 static std::string validate(IO &io, std::unique_ptr<ELFYAML::Chunk> &C);
1002};
1003
1004template <>
1005struct MappingTraits<ELFYAML::Object> {
1006 static void mapping(IO &IO, ELFYAML::Object &Object);
1007};
1008
1009template <> struct MappingTraits<ELFYAML::SectionOrType> {
1010 static void mapping(IO &IO, ELFYAML::SectionOrType &sectionOrType);
1011};
1012
1013} // end namespace yaml
1014} // end namespace llvm
1015
1016#endif // LLVM_OBJECTYAML_ELFYAML_H
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file declares classes for handling the YAML representation of DWARF Debug Info.
std::string Name
Symbol * Sym
Definition: ELF_riscv.cpp:479
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
#define LLVM_YAML_STRONG_TYPEDEF(_base, _type)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
Specialized YAMLIO scalar type for representing a binary blob.
Definition: YAML.h:63
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
std::string appendUniqueSuffix(StringRef Name, const Twine &Msg)
Definition: ELFEmitter.cpp:692
unsigned getDefaultShEntSize(unsigned EMachine, ELF_SHT SecType, StringRef SecName)
Definition: ELFYAML.h:77
StringRef dropUniqueSuffix(StringRef S)
Definition: ELFEmitter.cpp:699
bool shouldAllocateFileSpace(ArrayRef< ProgramHeader > Phdrs, const NoBitsSection &S)
@ EM_MIPS
Definition: ELF.h:142
@ SHT_GROUP
Definition: ELF.h:1104
@ SHT_REL
Definition: ELF.h:1098
@ SHT_LLVM_CALL_GRAPH_PROFILE
Definition: ELF.h:1129
@ SHT_SYMTAB
Definition: ELF.h:1091
@ SHT_RELR
Definition: ELF.h:1108
@ SHT_DYNAMIC
Definition: ELF.h:1095
@ SHT_SYMTAB_SHNDX
Definition: ELF.h:1105
@ SHT_RELA
Definition: ELF.h:1093
@ SHT_DYNSYM
Definition: ELF.h:1100
@ SHT_MIPS_ABIFLAGS
Definition: ELF.h:1167
@ SHT_GNU_versym
Definition: ELF.h:1141
@ SHT_HASH
Definition: ELF.h:1094
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
#define N
llvm::yaml::Hex32 Offset
Definition: ELFYAML.h:668
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:677
static bool classof(const Chunk *S)
Definition: ELFYAML.h:681
std::optional< std::vector< ARMIndexTableEntry > > Entries
Definition: ELFYAML.h:673
std::optional< std::vector< YAMLFlowString > > Symbols
Definition: ELFYAML.h:504
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:508
static bool classof(const Chunk *S)
Definition: ELFYAML.h:512
std::optional< uint64_t > NumBlocks
Definition: ELFYAML.h:171
std::optional< std::vector< BBEntry > > BBEntries
Definition: ELFYAML.h:172
llvm::yaml::Hex64 getFunctionAddress() const
Definition: ELFYAML.h:178
std::optional< uint64_t > NumBBRanges
Definition: ELFYAML.h:175
std::optional< std::vector< BBRangeEntry > > BBRanges
Definition: ELFYAML.h:176
llvm::yaml::Hex8 Feature
Definition: ELFYAML.h:167
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:349
static bool classof(const Chunk *S)
Definition: ELFYAML.h:353
std::optional< std::vector< BBAddrMapEntry > > Entries
Definition: ELFYAML.h:344
std::optional< std::vector< PGOAnalysisMapEntry > > PGOAnalyses
Definition: ELFYAML.h:345
std::optional< std::vector< CallGraphEntryWeight > > Entries
Definition: ELFYAML.h:555
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:559
static bool classof(const Chunk *S)
Definition: ELFYAML.h:563
Chunk(ChunkKind K, bool Implicit)
Definition: ELFYAML.h:247
StringRef Name
Definition: ELFYAML.h:240
std::optional< llvm::yaml::Hex64 > Offset
Definition: ELFYAML.h:241
ChunkKind Kind
Definition: ELFYAML.h:239
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:539
static bool classof(const Chunk *S)
Definition: ELFYAML.h:543
std::optional< std::vector< YAMLFlowString > > Libs
Definition: ELFYAML.h:535
llvm::yaml::Hex64 Val
Definition: ELFYAML.h:156
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:381
static bool classof(const Chunk *S)
Definition: ELFYAML.h:385
std::optional< std::vector< DynamicEntry > > Entries
Definition: ELFYAML.h:377
std::optional< llvm::yaml::Hex16 > EPhNum
Definition: ELFYAML.h:126
std::optional< llvm::yaml::Hex64 > EShOff
Definition: ELFYAML.h:128
std::optional< llvm::yaml::Hex64 > EPhOff
Definition: ELFYAML.h:124
ELF_ELFCLASS Class
Definition: ELFYAML.h:114
std::optional< llvm::yaml::Hex16 > EShEntSize
Definition: ELFYAML.h:127
std::optional< llvm::yaml::Hex16 > EPhEntSize
Definition: ELFYAML.h:125
llvm::yaml::Hex8 ABIVersion
Definition: ELFYAML.h:117
std::optional< llvm::yaml::Hex16 > EShNum
Definition: ELFYAML.h:129
llvm::yaml::Hex64 Entry
Definition: ELFYAML.h:121
ELF_ELFOSABI OSABI
Definition: ELFYAML.h:116
std::optional< ELF_EM > Machine
Definition: ELFYAML.h:119
std::optional< StringRef > SectionHeaderStringTable
Definition: ELFYAML.h:122
std::optional< llvm::yaml::Hex16 > EShStrNdx
Definition: ELFYAML.h:130
llvm::yaml::Hex64 Size
Definition: ELFYAML.h:311
std::optional< yaml::BinaryRef > Pattern
Definition: ELFYAML.h:310
static bool classof(const Chunk *S)
Definition: ELFYAML.h:315
std::optional< llvm::yaml::Hex32 > MaskWords
Definition: ELFYAML.h:451
llvm::yaml::Hex32 SymNdx
Definition: ELFYAML.h:445
llvm::yaml::Hex32 Shift2
Definition: ELFYAML.h:454
std::optional< llvm::yaml::Hex32 > NBuckets
Definition: ELFYAML.h:441
std::optional< std::vector< llvm::yaml::Hex64 > > BloomFilter
Definition: ELFYAML.h:459
std::optional< std::vector< llvm::yaml::Hex32 > > HashBuckets
Definition: ELFYAML.h:460
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:465
static bool classof(const Chunk *S)
Definition: ELFYAML.h:472
std::optional< GnuHashHeader > Header
Definition: ELFYAML.h:458
std::optional< std::vector< llvm::yaml::Hex32 > > HashValues
Definition: ELFYAML.h:461
static bool classof(const Chunk *S)
Definition: ELFYAML.h:614
std::optional< std::vector< SectionOrType > > Members
Definition: ELFYAML.h:605
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:610
std::optional< StringRef > Signature
Definition: ELFYAML.h:606
std::optional< std::vector< uint32_t > > Chain
Definition: ELFYAML.h:421
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:423
std::optional< llvm::yaml::Hex64 > NChain
Definition: ELFYAML.h:430
static bool classof(const Chunk *S)
Definition: ELFYAML.h:434
std::optional< std::vector< uint32_t > > Bucket
Definition: ELFYAML.h:420
std::optional< llvm::yaml::Hex64 > NBucket
Definition: ELFYAML.h:429
std::optional< std::vector< LinkerOption > > Options
Definition: ELFYAML.h:521
static bool classof(const Chunk *S)
Definition: ELFYAML.h:529
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:525
llvm::yaml::Hex16 Version
Definition: ELFYAML.h:688
static bool classof(const Chunk *S)
Definition: ELFYAML.h:702
MIPS_AFL_FLAGS1 Flags1
Definition: ELFYAML.h:697
llvm::yaml::Hex8 ISARevision
Definition: ELFYAML.h:690
MIPS_AFL_EXT ISAExtension
Definition: ELFYAML.h:695
llvm::yaml::Hex32 Flags2
Definition: ELFYAML.h:698
static bool classof(const Chunk *S)
Definition: ELFYAML.h:404
yaml::BinaryRef Desc
Definition: ELFYAML.h:205
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:412
std::optional< std::vector< ELFYAML::NoteEntry > > Notes
Definition: ELFYAML.h:408
static bool classof(const Chunk *S)
Definition: ELFYAML.h:416
std::optional< std::vector< Symbol > > DynamicSymbols
Definition: ELFYAML.h:736
unsigned getMachine() const
Definition: ELFYAML.cpp:35
std::optional< DWARFYAML::Data > DWARF
Definition: ELFYAML.h:737
const SectionHeaderTable & getSectionHeaderTable() const
Definition: ELFYAML.h:747
FileHeader Header
Definition: ELFYAML.h:724
std::vector< std::unique_ptr< Chunk > > Chunks
Definition: ELFYAML.h:729
ELF_ELFOSABI getOSAbi() const
Definition: ELFYAML.cpp:33
std::vector< ProgramHeader > ProgramHeaders
Definition: ELFYAML.h:725
std::optional< std::vector< Symbol > > Symbols
Definition: ELFYAML.h:735
std::vector< Section * > getSections()
Definition: ELFYAML.h:739
std::optional< std::vector< SuccessorEntry > > Successors
Definition: ELFYAML.h:192
std::optional< std::vector< PGOBBEntry > > PGOBBEntries
Definition: ELFYAML.h:195
std::optional< uint64_t > FuncEntryCount
Definition: ELFYAML.h:194
std::optional< llvm::yaml::Hex64 > Align
Definition: ELFYAML.h:712
llvm::yaml::Hex64 PAddr
Definition: ELFYAML.h:711
std::optional< llvm::yaml::Hex64 > Offset
Definition: ELFYAML.h:715
llvm::yaml::Hex64 VAddr
Definition: ELFYAML.h:710
std::optional< llvm::yaml::Hex64 > MemSize
Definition: ELFYAML.h:714
std::optional< StringRef > FirstSec
Definition: ELFYAML.h:716
std::optional< StringRef > LastSec
Definition: ELFYAML.h:717
std::optional< llvm::yaml::Hex64 > FileSize
Definition: ELFYAML.h:713
std::vector< Chunk * > Chunks
Definition: ELFYAML.h:720
static bool classof(const Chunk *S)
Definition: ELFYAML.h:393
std::optional< llvm::yaml::Hex64 > Info
Definition: ELFYAML.h:389
std::optional< std::vector< uint8_t > > ContentBuf
Definition: ELFYAML.h:398
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:630
std::optional< std::vector< Relocation > > Relocations
Definition: ELFYAML.h:625
static bool classof(const Chunk *S)
Definition: ELFYAML.h:634
std::optional< StringRef > Symbol
Definition: ELFYAML.h:621
llvm::yaml::Hex64 Offset
Definition: ELFYAML.h:618
static bool classof(const Chunk *S)
Definition: ELFYAML.h:648
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:644
std::optional< std::vector< llvm::yaml::Hex64 > > Entries
Definition: ELFYAML.h:640
std::optional< std::vector< SectionHeader > > Excluded
Definition: ELFYAML.h:327
static constexpr StringRef TypeStr
Definition: ELFYAML.h:340
std::optional< bool > NoHeaders
Definition: ELFYAML.h:328
static bool classof(const Chunk *S)
Definition: ELFYAML.h:322
SectionHeaderTable(bool IsImplicit)
Definition: ELFYAML.h:319
size_t getNumHeaders(size_t SectionsNum) const
Definition: ELFYAML.h:330
std::optional< std::vector< SectionHeader > > Sections
Definition: ELFYAML.h:326
std::optional< llvm::yaml::Hex64 > Address
Definition: ELFYAML.h:254
std::optional< StringRef > Link
Definition: ELFYAML.h:255
Section(ChunkKind Kind, bool IsImplicit=false)
Definition: ELFYAML.h:265
std::optional< llvm::yaml::Hex64 > Size
Definition: ELFYAML.h:260
static bool classof(const Chunk *S)
Definition: ELFYAML.h:267
std::optional< llvm::yaml::Hex64 > ShAddrAlign
Definition: ELFYAML.h:282
llvm::yaml::Hex64 AddressAlign
Definition: ELFYAML.h:256
unsigned OriginalSecNdx
Definition: ELFYAML.h:263
std::optional< ELF_SHF > Flags
Definition: ELFYAML.h:253
std::optional< ELF_SHT > ShType
Definition: ELFYAML.h:303
std::optional< llvm::yaml::Hex64 > ShOffset
Definition: ELFYAML.h:290
virtual std::vector< std::pair< StringRef, bool > > getEntries() const
Definition: ELFYAML.h:274
std::optional< llvm::yaml::Hex64 > ShFlags
Definition: ELFYAML.h:297
std::optional< llvm::yaml::Hex64 > ShName
Definition: ELFYAML.h:286
std::optional< yaml::BinaryRef > Content
Definition: ELFYAML.h:259
std::optional< llvm::yaml::Hex64 > EntSize
Definition: ELFYAML.h:257
std::optional< llvm::yaml::Hex64 > ShSize
Definition: ELFYAML.h:294
llvm::yaml::Hex64 Size
Definition: ELFYAML.h:200
llvm::yaml::Hex64 Address
Definition: ELFYAML.h:199
static bool classof(const Chunk *S)
Definition: ELFYAML.h:367
static bool nameMatches(StringRef Name)
Definition: ELFYAML.h:371
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:363
std::optional< std::vector< StackSizeEntry > > Entries
Definition: ELFYAML.h:359
std::optional< ELF_SHN > Index
Definition: ELFYAML.h:141
std::optional< StringRef > Section
Definition: ELFYAML.h:140
std::optional< uint8_t > Other
Definition: ELFYAML.h:145
std::optional< uint32_t > StName
Definition: ELFYAML.h:147
std::optional< llvm::yaml::Hex64 > Value
Definition: ELFYAML.h:143
std::optional< llvm::yaml::Hex64 > Size
Definition: ELFYAML.h:144
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:658
static bool classof(const Chunk *S)
Definition: ELFYAML.h:662
std::optional< std::vector< uint32_t > > Entries
Definition: ELFYAML.h:654
std::optional< std::vector< uint16_t > > Entries
Definition: ELFYAML.h:569
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:573
static bool classof(const Chunk *S)
Definition: ELFYAML.h:577
std::optional< uint16_t > Flags
Definition: ELFYAML.h:582
std::optional< uint16_t > VDAux
Definition: ELFYAML.h:585
std::vector< StringRef > VerNames
Definition: ELFYAML.h:586
std::optional< uint16_t > VersionNdx
Definition: ELFYAML.h:583
std::optional< uint16_t > Version
Definition: ELFYAML.h:581
std::optional< uint32_t > Hash
Definition: ELFYAML.h:584
static bool classof(const Chunk *S)
Definition: ELFYAML.h:599
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:595
std::optional< llvm::yaml::Hex64 > Info
Definition: ELFYAML.h:591
std::optional< std::vector< VerdefEntry > > Entries
Definition: ELFYAML.h:590
std::vector< VernauxEntry > AuxV
Definition: ELFYAML.h:485
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition: ELFYAML.h:494
std::optional< llvm::yaml::Hex64 > Info
Definition: ELFYAML.h:490
static bool classof(const Chunk *S)
Definition: ELFYAML.h:498
std::optional< std::vector< VerneedEntry > > VerneedV
Definition: ELFYAML.h:489