LLVM 23.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"
25#include <cstdint>
26#include <memory>
27#include <optional>
28#include <vector>
29
30namespace llvm {
31namespace ELFYAML {
32
34std::string appendUniqueSuffix(StringRef Name, const Twine& Msg);
35
36// These types are invariant across 32/64-bit ELF, so for simplicity just
37// directly give them their exact sizes. We don't need to worry about
38// endianness because these are just the types in the YAMLIO structures,
39// and are appropriately converted to the necessary endianness when
40// reading/generating binary object files.
41// The naming of these types is intended to be ELF_PREFIX, where PREFIX is
42// the common prefix of the respective constants. E.g. ELF_EM corresponds
43// to the `e_machine` constants, like `EM_X86_64`.
44// In the future, these would probably be better suited by C++11 enum
45// class's with appropriate fixed underlying type.
52// Just use 64, since it can hold 32-bit values too.
54// Just use 64, since it can hold 32-bit values too.
60// Just use 64, since it can hold 32-bit values too.
66
71LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_FLAGS1)
73
75LLVM_YAML_STRONG_TYPEDEF(int64_t, YAMLIntUInt)
76
77template <class ELFT>
78unsigned getDefaultShEntSize(unsigned EMachine, ELF_SHT SecType,
79 StringRef SecName) {
80 if (EMachine == ELF::EM_MIPS && SecType == ELF::SHT_MIPS_ABIFLAGS)
82
83 switch (SecType) {
84 case ELF::SHT_SYMTAB:
85 case ELF::SHT_DYNSYM:
86 return sizeof(typename ELFT::Sym);
87 case ELF::SHT_GROUP:
88 return sizeof(typename ELFT::Word);
89 case ELF::SHT_REL:
90 return sizeof(typename ELFT::Rel);
91 case ELF::SHT_RELA:
92 return sizeof(typename ELFT::Rela);
93 case ELF::SHT_RELR:
94 return sizeof(typename ELFT::Relr);
96 return sizeof(typename ELFT::Dyn);
97 case ELF::SHT_HASH:
98 return sizeof(typename ELFT::Word);
100 return sizeof(typename ELFT::Word);
102 return sizeof(typename ELFT::Half);
105 default:
106 if (SecName == ".debug_str")
107 return 1;
108 return 0;
109 }
110}
111
112// For now, hardcode 64 bits everywhere that 32 or 64 would be needed
113// since 64-bit can hold 32-bit values too.
115 ELF_ELFCLASS Class;
116 ELF_ELFDATA Data;
117 ELF_ELFOSABI OSABI;
118 llvm::yaml::Hex8 ABIVersion;
119 ELF_ET Type;
120 std::optional<ELF_EM> Machine;
121 std::optional<ELF_EF> Flags;
122 llvm::yaml::Hex64 Entry;
123 std::optional<StringRef> SectionHeaderStringTable;
124
125 std::optional<llvm::yaml::Hex64> EPhOff;
126 std::optional<llvm::yaml::Hex16> EPhEntSize;
127 std::optional<llvm::yaml::Hex16> EPhNum;
128 std::optional<llvm::yaml::Hex16> EShEntSize;
129 std::optional<llvm::yaml::Hex64> EShOff;
130 std::optional<llvm::yaml::Hex16> EShNum;
131 std::optional<llvm::yaml::Hex16> EShStrNdx;
132};
133
137
138struct Symbol {
140 ELF_STT Type;
141 std::optional<StringRef> Section;
142 std::optional<ELF_SHN> Index;
143 ELF_STB Binding;
144 std::optional<llvm::yaml::Hex64> Value;
145 std::optional<llvm::yaml::Hex64> Size;
146 std::optional<uint8_t> Other;
147
148 std::optional<uint32_t> StName;
149};
150
154
156 ELF_DYNTAG Tag;
157 llvm::yaml::Hex64 Val;
158};
159
161 llvm::yaml::Hex64 Address;
162 llvm::yaml::Hex64 Size;
163};
164
170
171struct Chunk {
200
203 std::optional<llvm::yaml::Hex64> Offset;
204
205 // Usually chunks are not created implicitly, but rather loaded from YAML.
206 // This flag is used to signal whether this is the case or not.
208
210 virtual ~Chunk();
211};
212
213struct Section : public Chunk {
214 ELF_SHT Type;
215 std::optional<ELF_SHF> Flags;
216 std::optional<llvm::yaml::Hex64> Address;
217 std::optional<StringRef> Link;
218 llvm::yaml::Hex64 AddressAlign;
219 std::optional<llvm::yaml::Hex64> EntSize;
220
221 std::optional<yaml::BinaryRef> Content;
222 std::optional<llvm::yaml::Hex64> Size;
223
224 // Holds the original section index.
226
228
229 static bool classof(const Chunk *S) {
231 }
232
233 // Some derived sections might have their own special entries. This method
234 // returns a vector of <entry name, is used> pairs. It is used for section
235 // validation.
236 virtual std::vector<std::pair<StringRef, bool>> getEntries() const {
237 return {};
238 };
239
240 // The following members are used to override section fields which is
241 // useful for creating invalid objects.
242
243 // This can be used to override the sh_addralign field.
244 std::optional<llvm::yaml::Hex64> ShAddrAlign;
245
246 // This can be used to override the offset stored in the sh_name field.
247 // It does not affect the name stored in the string table.
248 std::optional<llvm::yaml::Hex64> ShName;
249
250 // This can be used to override the sh_offset field. It does not place the
251 // section data at the offset specified.
252 std::optional<llvm::yaml::Hex64> ShOffset;
253
254 // This can be used to override the sh_size field. It does not affect the
255 // content written.
256 std::optional<llvm::yaml::Hex64> ShSize;
257
258 // This can be used to override the sh_flags field.
259 std::optional<llvm::yaml::Hex64> ShFlags;
260
261 // This can be used to override the sh_type field. It is useful when we
262 // want to use specific YAML keys for a section of a particular type to
263 // describe the content, but still want to have a different final type
264 // for the section.
265 std::optional<ELF_SHT> ShType;
266};
267
268// Fill is a block of data which is placed outside of sections. It is
269// not present in the sections header table, but it might affect the output file
270// size and program headers produced.
271struct Fill : Chunk {
272 std::optional<yaml::BinaryRef> Pattern;
273 llvm::yaml::Hex64 Size;
274
275 Fill() : Chunk(ChunkKind::Fill, /*Implicit=*/false) {}
276
277 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Fill; }
278};
279
283
284 static bool classof(const Chunk *S) {
286 }
287
288 std::optional<std::vector<SectionHeader>> Sections;
289 std::optional<std::vector<SectionHeader>> Excluded;
290 std::optional<bool> NoHeaders;
291
292 size_t getNumHeaders(size_t SectionsNum) const {
293 if (IsImplicit || isDefault())
294 return SectionsNum;
295 if (NoHeaders)
296 return (*NoHeaders) ? 0 : SectionsNum;
297 return (Sections ? Sections->size() : 0) + /*Null section*/ 1;
298 }
299
300 bool isDefault() const { return !Sections && !Excluded && !NoHeaders; }
301
302 static constexpr StringRef TypeStr = "SectionHeaderTable";
303};
304
306 std::optional<std::vector<BBAddrMapYAML::BBAddrMapEntry>> Entries;
307 std::optional<std::vector<BBAddrMapYAML::PGOAnalysisMapEntry>> PGOAnalyses;
308
310
311 std::vector<std::pair<StringRef, bool>> getEntries() const override {
312 return {{"Entries", Entries.has_value()}};
313 };
314
315 static bool classof(const Chunk *S) {
316 return S->Kind == ChunkKind::BBAddrMap;
317 }
318};
319
321 std::optional<std::vector<StackSizeEntry>> Entries;
322
324
325 std::vector<std::pair<StringRef, bool>> getEntries() const override {
326 return {{"Entries", Entries.has_value()}};
327 };
328
329 static bool classof(const Chunk *S) {
330 return S->Kind == ChunkKind::StackSizes;
331 }
332
334 return Name == ".stack_sizes";
335 }
336};
337
339 std::optional<std::vector<DynamicEntry>> Entries;
340
342
343 std::vector<std::pair<StringRef, bool>> getEntries() const override {
344 return {{"Entries", Entries.has_value()}};
345 };
346
347 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Dynamic; }
348};
349
351 std::optional<llvm::yaml::Hex64> Info;
352
354
355 static bool classof(const Chunk *S) {
356 return S->Kind == ChunkKind::RawContent;
357 }
358
359 // Is used when a content is read as an array of bytes.
360 std::optional<std::vector<uint8_t>> ContentBuf;
361};
362
365
366 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::NoBits; }
367};
368
370 std::optional<std::vector<ELFYAML::NoteEntry>> Notes;
371
373
374 std::vector<std::pair<StringRef, bool>> getEntries() const override {
375 return {{"Notes", Notes.has_value()}};
376 };
377
378 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Note; }
379};
380
382 std::optional<std::vector<uint32_t>> Bucket;
383 std::optional<std::vector<uint32_t>> Chain;
384
385 std::vector<std::pair<StringRef, bool>> getEntries() const override {
386 return {{"Bucket", Bucket.has_value()}, {"Chain", Chain.has_value()}};
387 };
388
389 // The following members are used to override section fields.
390 // This is useful for creating invalid objects.
391 std::optional<llvm::yaml::Hex64> NBucket;
392 std::optional<llvm::yaml::Hex64> NChain;
393
395
396 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Hash; }
397};
398
400 // The number of hash buckets.
401 // Not used when dumping the object, but can be used to override
402 // the real number of buckets when emiting an object from a YAML document.
403 std::optional<llvm::yaml::Hex32> NBuckets;
404
405 // Index of the first symbol in the dynamic symbol table
406 // included in the hash table.
407 llvm::yaml::Hex32 SymNdx;
408
409 // The number of words in the Bloom filter.
410 // Not used when dumping the object, but can be used to override the real
411 // number of words in the Bloom filter when emiting an object from a YAML
412 // document.
413 std::optional<llvm::yaml::Hex32> MaskWords;
414
415 // A shift constant used by the Bloom filter.
416 llvm::yaml::Hex32 Shift2;
417};
418
420 std::optional<GnuHashHeader> Header;
421 std::optional<std::vector<llvm::yaml::Hex64>> BloomFilter;
422 std::optional<std::vector<llvm::yaml::Hex32>> HashBuckets;
423 std::optional<std::vector<llvm::yaml::Hex32>> HashValues;
424
426
427 std::vector<std::pair<StringRef, bool>> getEntries() const override {
428 return {{"Header", Header.has_value()},
429 {"BloomFilter", BloomFilter.has_value()},
430 {"HashBuckets", HashBuckets.has_value()},
431 {"HashValues", HashValues.has_value()}};
432 };
433
434 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::GnuHash; }
435};
436
443
447 std::vector<VernauxEntry> AuxV;
448};
449
451 std::optional<std::vector<VerneedEntry>> VerneedV;
452 std::optional<llvm::yaml::Hex64> Info;
453
455
456 std::vector<std::pair<StringRef, bool>> getEntries() const override {
457 return {{"Dependencies", VerneedV.has_value()}};
458 };
459
460 static bool classof(const Chunk *S) {
461 return S->Kind == ChunkKind::Verneed;
462 }
463};
464
466 std::optional<std::vector<YAMLFlowString>> Symbols;
467
469
470 std::vector<std::pair<StringRef, bool>> getEntries() const override {
471 return {{"Symbols", Symbols.has_value()}};
472 };
473
474 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Addrsig; }
475};
476
481
483 std::optional<std::vector<LinkerOption>> Options;
484
486
487 std::vector<std::pair<StringRef, bool>> getEntries() const override {
488 return {{"Options", Options.has_value()}};
489 };
490
491 static bool classof(const Chunk *S) {
492 return S->Kind == ChunkKind::LinkerOptions;
493 }
494};
495
497 std::optional<std::vector<YAMLFlowString>> Libs;
498
500
501 std::vector<std::pair<StringRef, bool>> getEntries() const override {
502 return {{"Libraries", Libs.has_value()}};
503 };
504
505 static bool classof(const Chunk *S) {
507 }
508};
509
510// Represents the call graph profile section entry.
512 // The weight of the edge.
514};
515
517 std::optional<std::vector<CallGraphEntryWeight>> Entries;
518
520
521 std::vector<std::pair<StringRef, bool>> getEntries() const override {
522 return {{"Entries", Entries.has_value()}};
523 };
524
525 static bool classof(const Chunk *S) {
527 }
528};
529
531 std::optional<std::vector<uint16_t>> Entries;
532
534
535 std::vector<std::pair<StringRef, bool>> getEntries() const override {
536 return {{"Entries", Entries.has_value()}};
537 };
538
539 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Symver; }
540};
541
543 std::optional<uint16_t> Version;
544 std::optional<uint16_t> Flags;
545 std::optional<uint16_t> VersionNdx;
546 std::optional<uint32_t> Hash;
547 std::optional<uint16_t> VDAux;
548 std::vector<StringRef> VerNames;
549};
550
552 std::optional<std::vector<VerdefEntry>> Entries;
553 std::optional<llvm::yaml::Hex64> Info;
554
556
557 std::vector<std::pair<StringRef, bool>> getEntries() const override {
558 return {{"Entries", Entries.has_value()}};
559 };
560
561 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Verdef; }
562};
563
565 // Members of a group contain a flag and a list of section indices
566 // that are part of the group.
567 std::optional<std::vector<SectionOrType>> Members;
568 std::optional<StringRef> Signature; /* Info */
569
571
572 std::vector<std::pair<StringRef, bool>> getEntries() const override {
573 return {{"Members", Members.has_value()}};
574 };
575
576 static bool classof(const Chunk *S) { return S->Kind == ChunkKind::Group; }
577};
578
580 llvm::yaml::Hex64 Offset;
581 YAMLIntUInt Addend;
582 ELF_REL Type;
583 std::optional<StringRef> Symbol;
584};
585
587 std::optional<std::vector<Relocation>> Relocations;
589
591
592 std::vector<std::pair<StringRef, bool>> getEntries() const override {
593 return {{"Relocations", Relocations.has_value()}};
594 };
595
596 static bool classof(const Chunk *S) {
597 return S->Kind == ChunkKind::Relocation;
598 }
599};
600
602 std::optional<std::vector<llvm::yaml::Hex64>> Entries;
603
605
606 std::vector<std::pair<StringRef, bool>> getEntries() const override {
607 return {{"Entries", Entries.has_value()}};
608 };
609
610 static bool classof(const Chunk *S) {
611 return S->Kind == ChunkKind::Relr;
612 }
613};
614
616 std::optional<std::vector<uint32_t>> Entries;
617
619
620 std::vector<std::pair<StringRef, bool>> getEntries() const override {
621 return {{"Entries", Entries.has_value()}};
622 };
623
624 static bool classof(const Chunk *S) {
626 }
627};
628
630 llvm::yaml::Hex32 Offset;
631 llvm::yaml::Hex32 Value;
632};
633
635 std::optional<std::vector<ARMIndexTableEntry>> Entries;
636
638
639 std::vector<std::pair<StringRef, bool>> getEntries() const override {
640 return {{"Entries", Entries.has_value()}};
641 };
642
643 static bool classof(const Chunk *S) {
644 return S->Kind == ChunkKind::ARMIndexTable;
645 }
646};
647
648// Represents .MIPS.abiflags section
650 llvm::yaml::Hex16 Version;
651 MIPS_ISA ISALevel;
652 llvm::yaml::Hex8 ISARevision;
653 MIPS_AFL_REG GPRSize;
654 MIPS_AFL_REG CPR1Size;
655 MIPS_AFL_REG CPR2Size;
656 MIPS_ABI_FP FpABI;
657 MIPS_AFL_EXT ISAExtension;
658 MIPS_AFL_ASE ASEs;
659 MIPS_AFL_FLAGS1 Flags1;
660 llvm::yaml::Hex32 Flags2;
661
663
664 static bool classof(const Chunk *S) {
665 return S->Kind == ChunkKind::MipsABIFlags;
666 }
667};
668
670 ELF_PT Type;
671 ELF_PF Flags;
672 llvm::yaml::Hex64 VAddr;
673 llvm::yaml::Hex64 PAddr;
674 std::optional<llvm::yaml::Hex64> Align;
675 std::optional<llvm::yaml::Hex64> FileSize;
676 std::optional<llvm::yaml::Hex64> MemSize;
677 std::optional<llvm::yaml::Hex64> Offset;
678 std::optional<StringRef> FirstSec;
679 std::optional<StringRef> LastSec;
680
681 // This vector contains all chunks from [FirstSec, LastSec].
682 std::vector<Chunk *> Chunks;
683};
684
685struct Object {
687 std::vector<ProgramHeader> ProgramHeaders;
688
689 // An object might contain output section descriptions as well as
690 // custom data that does not belong to any section.
691 std::vector<std::unique_ptr<Chunk>> Chunks;
692
693 // Although in reality the symbols reside in a section, it is a lot
694 // cleaner and nicer if we read them from the YAML as a separate
695 // top-level key, which automatically ensures that invariants like there
696 // being a single SHT_SYMTAB section are upheld.
697 std::optional<std::vector<Symbol>> Symbols;
698 std::optional<std::vector<Symbol>> DynamicSymbols;
699 std::optional<DWARFYAML::Data> DWARF;
700
701 std::vector<Section *> getSections() {
702 std::vector<Section *> Ret;
703 for (const std::unique_ptr<Chunk> &Sec : Chunks)
704 if (auto S = dyn_cast<ELFYAML::Section>(Sec.get()))
705 Ret.push_back(S);
706 return Ret;
707 }
708
710 for (const std::unique_ptr<Chunk> &C : Chunks)
711 if (auto *S = dyn_cast<ELFYAML::SectionHeaderTable>(C.get()))
712 return *S;
713 llvm_unreachable("the section header table chunk must always be present");
714 }
715
716 ELF_ELFOSABI getOSAbi() const;
717 unsigned getMachine() const;
718};
719
721 const NoBitsSection &S);
722
723} // end namespace ELFYAML
724} // end namespace llvm
725
733LLVM_YAML_IS_SEQUENCE_VECTOR(std::unique_ptr<llvm::ELFYAML::Chunk>)
741
742namespace llvm {
743namespace yaml {
744
745template <> struct ScalarTraits<ELFYAML::YAMLIntUInt> {
746 static void output(const ELFYAML::YAMLIntUInt &Val, void *Ctx,
747 raw_ostream &Out);
748 static StringRef input(StringRef Scalar, void *Ctx,
749 ELFYAML::YAMLIntUInt &Val);
751};
752
753template <>
755 static void enumeration(IO &IO, ELFYAML::ELF_ET &Value);
756};
757
758template <> struct ScalarEnumerationTraits<ELFYAML::ELF_PT> {
759 static void enumeration(IO &IO, ELFYAML::ELF_PT &Value);
760};
761
762template <> struct ScalarEnumerationTraits<ELFYAML::ELF_NT> {
763 static void enumeration(IO &IO, ELFYAML::ELF_NT &Value);
764};
765
766template <>
768 static void enumeration(IO &IO, ELFYAML::ELF_EM &Value);
769};
770
771template <>
772struct ScalarEnumerationTraits<ELFYAML::ELF_ELFCLASS> {
773 static void enumeration(IO &IO, ELFYAML::ELF_ELFCLASS &Value);
774};
775
776template <>
777struct ScalarEnumerationTraits<ELFYAML::ELF_ELFDATA> {
778 static void enumeration(IO &IO, ELFYAML::ELF_ELFDATA &Value);
779};
780
781template <>
782struct ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI> {
783 static void enumeration(IO &IO, ELFYAML::ELF_ELFOSABI &Value);
784};
785
786template <>
788 static void bitset(IO &IO, ELFYAML::ELF_EF &Value);
789};
790
791template <> struct ScalarBitSetTraits<ELFYAML::ELF_PF> {
792 static void bitset(IO &IO, ELFYAML::ELF_PF &Value);
793};
794
795template <>
797 static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value);
798};
799
800template <>
801struct ScalarBitSetTraits<ELFYAML::ELF_SHF> {
802 static void bitset(IO &IO, ELFYAML::ELF_SHF &Value);
803};
804
805template <> struct ScalarEnumerationTraits<ELFYAML::ELF_SHN> {
806 static void enumeration(IO &IO, ELFYAML::ELF_SHN &Value);
807};
808
809template <> struct ScalarEnumerationTraits<ELFYAML::ELF_STB> {
810 static void enumeration(IO &IO, ELFYAML::ELF_STB &Value);
811};
812
813template <>
815 static void enumeration(IO &IO, ELFYAML::ELF_STT &Value);
816};
817
818template <>
820 static void enumeration(IO &IO, ELFYAML::ELF_REL &Value);
821};
822
823template <>
824struct ScalarEnumerationTraits<ELFYAML::ELF_DYNTAG> {
825 static void enumeration(IO &IO, ELFYAML::ELF_DYNTAG &Value);
826};
827
828template <>
830 static void enumeration(IO &IO, ELFYAML::ELF_RSS &Value);
831};
832
833template <>
834struct ScalarEnumerationTraits<ELFYAML::MIPS_AFL_REG> {
835 static void enumeration(IO &IO, ELFYAML::MIPS_AFL_REG &Value);
836};
837
838template <>
839struct ScalarEnumerationTraits<ELFYAML::MIPS_ABI_FP> {
840 static void enumeration(IO &IO, ELFYAML::MIPS_ABI_FP &Value);
841};
842
843template <>
844struct ScalarEnumerationTraits<ELFYAML::MIPS_AFL_EXT> {
845 static void enumeration(IO &IO, ELFYAML::MIPS_AFL_EXT &Value);
846};
847
848template <>
850 static void enumeration(IO &IO, ELFYAML::MIPS_ISA &Value);
851};
852
853template <>
854struct ScalarBitSetTraits<ELFYAML::MIPS_AFL_ASE> {
855 static void bitset(IO &IO, ELFYAML::MIPS_AFL_ASE &Value);
856};
857
858template <>
859struct ScalarBitSetTraits<ELFYAML::MIPS_AFL_FLAGS1> {
860 static void bitset(IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value);
861};
862
863template <>
864struct MappingTraits<ELFYAML::FileHeader> {
865 static void mapping(IO &IO, ELFYAML::FileHeader &FileHdr);
866};
867
868template <> struct MappingTraits<ELFYAML::SectionHeader> {
869 static void mapping(IO &IO, ELFYAML::SectionHeader &SHdr);
870};
871
872template <> struct MappingTraits<ELFYAML::ProgramHeader> {
873 static void mapping(IO &IO, ELFYAML::ProgramHeader &FileHdr);
874 static std::string validate(IO &IO, ELFYAML::ProgramHeader &FileHdr);
875};
876
877template <>
878struct MappingTraits<ELFYAML::Symbol> {
879 static void mapping(IO &IO, ELFYAML::Symbol &Symbol);
880 static std::string validate(IO &IO, ELFYAML::Symbol &Symbol);
881};
882
883template <> struct MappingTraits<ELFYAML::StackSizeEntry> {
884 static void mapping(IO &IO, ELFYAML::StackSizeEntry &Rel);
885};
886
887template <> struct MappingTraits<ELFYAML::GnuHashHeader> {
888 static void mapping(IO &IO, ELFYAML::GnuHashHeader &Rel);
889};
890
891template <> struct MappingTraits<ELFYAML::DynamicEntry> {
892 static void mapping(IO &IO, ELFYAML::DynamicEntry &Rel);
893};
894
895template <> struct MappingTraits<ELFYAML::NoteEntry> {
896 static void mapping(IO &IO, ELFYAML::NoteEntry &N);
897};
898
899template <> struct MappingTraits<ELFYAML::VerdefEntry> {
900 static void mapping(IO &IO, ELFYAML::VerdefEntry &E);
901};
902
903template <> struct MappingTraits<ELFYAML::VerneedEntry> {
904 static void mapping(IO &IO, ELFYAML::VerneedEntry &E);
905};
906
907template <> struct MappingTraits<ELFYAML::VernauxEntry> {
908 static void mapping(IO &IO, ELFYAML::VernauxEntry &E);
909};
910
911template <> struct MappingTraits<ELFYAML::LinkerOption> {
912 static void mapping(IO &IO, ELFYAML::LinkerOption &Sym);
913};
914
915template <> struct MappingTraits<ELFYAML::CallGraphEntryWeight> {
917};
918
919template <> struct MappingTraits<ELFYAML::Relocation> {
920 static void mapping(IO &IO, ELFYAML::Relocation &Rel);
921};
922
923template <> struct MappingTraits<ELFYAML::ARMIndexTableEntry> {
924 static void mapping(IO &IO, ELFYAML::ARMIndexTableEntry &E);
925};
926
927template <> struct MappingTraits<std::unique_ptr<ELFYAML::Chunk>> {
928 static void mapping(IO &IO, std::unique_ptr<ELFYAML::Chunk> &C);
929 static std::string validate(IO &io, std::unique_ptr<ELFYAML::Chunk> &C);
930};
931
932template <>
933struct MappingTraits<ELFYAML::Object> {
934 static void mapping(IO &IO, ELFYAML::Object &Object);
935};
936
937template <> struct MappingTraits<ELFYAML::SectionOrType> {
938 static void mapping(IO &IO, ELFYAML::SectionOrType &sectionOrType);
939};
940
941} // end namespace yaml
942} // end namespace llvm
943
944#endif // LLVM_OBJECTYAML_ELFYAML_H
This file declares the YAML representation of BB address maps (SHT_LLVM_BB_ADDR_MAP / ....
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file declares classes for handling the YAML representation of DWARF Debug Info.
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
Utility for declaring that a std::vector of a particular type should be considered a YAML sequence.
#define LLVM_YAML_STRONG_TYPEDEF(_base, _type)
YAML I/O does conversion based on types. But often native data types are just a typedef of built in i...
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
Specialized YAMLIO scalar type for representing a binary blob.
Definition YAML.h:64
#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)
unsigned getDefaultShEntSize(unsigned EMachine, ELF_SHT SecType, StringRef SecName)
Definition ELFYAML.h:78
StringRef dropUniqueSuffix(StringRef S)
bool shouldAllocateFileSpace(ArrayRef< ProgramHeader > Phdrs, const NoBitsSection &S)
@ EM_MIPS
Definition ELF.h:146
@ SHT_GROUP
Definition ELF.h:1162
@ SHT_REL
Definition ELF.h:1156
@ SHT_LLVM_CALL_GRAPH_PROFILE
Definition ELF.h:1185
@ SHT_SYMTAB
Definition ELF.h:1149
@ SHT_RELR
Definition ELF.h:1166
@ SHT_DYNAMIC
Definition ELF.h:1153
@ SHT_SYMTAB_SHNDX
Definition ELF.h:1163
@ SHT_RELA
Definition ELF.h:1151
@ SHT_DYNSYM
Definition ELF.h:1158
@ SHT_MIPS_ABIFLAGS
Definition ELF.h:1228
@ SHT_GNU_versym
Definition ELF.h:1200
@ SHT_HASH
Definition ELF.h:1152
QuotingType
Describe which type of quotes should be used when quoting is necessary.
Definition YAMLTraits.h:132
This is an optimization pass for GlobalISel generic memory operations.
@ Implicit
Not emitted register (e.g. carry, or temporary result).
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:874
#define N
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:639
static bool classof(const Chunk *S)
Definition ELFYAML.h:643
std::optional< std::vector< ARMIndexTableEntry > > Entries
Definition ELFYAML.h:635
std::optional< std::vector< YAMLFlowString > > Symbols
Definition ELFYAML.h:466
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:470
static bool classof(const Chunk *S)
Definition ELFYAML.h:474
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:311
std::optional< std::vector< BBAddrMapYAML::PGOAnalysisMapEntry > > PGOAnalyses
Definition ELFYAML.h:307
static bool classof(const Chunk *S)
Definition ELFYAML.h:315
std::optional< std::vector< BBAddrMapYAML::BBAddrMapEntry > > Entries
Definition ELFYAML.h:306
std::optional< std::vector< CallGraphEntryWeight > > Entries
Definition ELFYAML.h:517
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:521
static bool classof(const Chunk *S)
Definition ELFYAML.h:525
Chunk(ChunkKind K, bool Implicit)
Definition ELFYAML.h:209
std::optional< llvm::yaml::Hex64 > Offset
Definition ELFYAML.h:203
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:501
static bool classof(const Chunk *S)
Definition ELFYAML.h:505
std::optional< std::vector< YAMLFlowString > > Libs
Definition ELFYAML.h:497
llvm::yaml::Hex64 Val
Definition ELFYAML.h:157
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:343
static bool classof(const Chunk *S)
Definition ELFYAML.h:347
std::optional< std::vector< DynamicEntry > > Entries
Definition ELFYAML.h:339
std::optional< llvm::yaml::Hex16 > EPhNum
Definition ELFYAML.h:127
std::optional< llvm::yaml::Hex64 > EShOff
Definition ELFYAML.h:129
std::optional< llvm::yaml::Hex64 > EPhOff
Definition ELFYAML.h:125
std::optional< llvm::yaml::Hex16 > EShEntSize
Definition ELFYAML.h:128
std::optional< llvm::yaml::Hex16 > EPhEntSize
Definition ELFYAML.h:126
llvm::yaml::Hex8 ABIVersion
Definition ELFYAML.h:118
std::optional< llvm::yaml::Hex16 > EShNum
Definition ELFYAML.h:130
llvm::yaml::Hex64 Entry
Definition ELFYAML.h:122
std::optional< ELF_EF > Flags
Definition ELFYAML.h:121
std::optional< ELF_EM > Machine
Definition ELFYAML.h:120
std::optional< StringRef > SectionHeaderStringTable
Definition ELFYAML.h:123
std::optional< llvm::yaml::Hex16 > EShStrNdx
Definition ELFYAML.h:131
llvm::yaml::Hex64 Size
Definition ELFYAML.h:273
std::optional< yaml::BinaryRef > Pattern
Definition ELFYAML.h:272
static bool classof(const Chunk *S)
Definition ELFYAML.h:277
std::optional< llvm::yaml::Hex32 > MaskWords
Definition ELFYAML.h:413
llvm::yaml::Hex32 SymNdx
Definition ELFYAML.h:407
llvm::yaml::Hex32 Shift2
Definition ELFYAML.h:416
std::optional< llvm::yaml::Hex32 > NBuckets
Definition ELFYAML.h:403
std::optional< std::vector< llvm::yaml::Hex64 > > BloomFilter
Definition ELFYAML.h:421
std::optional< std::vector< llvm::yaml::Hex32 > > HashBuckets
Definition ELFYAML.h:422
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:427
static bool classof(const Chunk *S)
Definition ELFYAML.h:434
std::optional< GnuHashHeader > Header
Definition ELFYAML.h:420
std::optional< std::vector< llvm::yaml::Hex32 > > HashValues
Definition ELFYAML.h:423
static bool classof(const Chunk *S)
Definition ELFYAML.h:576
std::optional< std::vector< SectionOrType > > Members
Definition ELFYAML.h:567
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:572
std::optional< StringRef > Signature
Definition ELFYAML.h:568
std::optional< std::vector< uint32_t > > Chain
Definition ELFYAML.h:383
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:385
std::optional< llvm::yaml::Hex64 > NChain
Definition ELFYAML.h:392
static bool classof(const Chunk *S)
Definition ELFYAML.h:396
std::optional< std::vector< uint32_t > > Bucket
Definition ELFYAML.h:382
std::optional< llvm::yaml::Hex64 > NBucket
Definition ELFYAML.h:391
std::optional< std::vector< LinkerOption > > Options
Definition ELFYAML.h:483
static bool classof(const Chunk *S)
Definition ELFYAML.h:491
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:487
llvm::yaml::Hex16 Version
Definition ELFYAML.h:650
static bool classof(const Chunk *S)
Definition ELFYAML.h:664
MIPS_AFL_FLAGS1 Flags1
Definition ELFYAML.h:659
llvm::yaml::Hex8 ISARevision
Definition ELFYAML.h:652
MIPS_AFL_EXT ISAExtension
Definition ELFYAML.h:657
llvm::yaml::Hex32 Flags2
Definition ELFYAML.h:660
static bool classof(const Chunk *S)
Definition ELFYAML.h:366
yaml::BinaryRef Desc
Definition ELFYAML.h:167
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:374
std::optional< std::vector< ELFYAML::NoteEntry > > Notes
Definition ELFYAML.h:370
static bool classof(const Chunk *S)
Definition ELFYAML.h:378
std::optional< std::vector< Symbol > > DynamicSymbols
Definition ELFYAML.h:698
unsigned getMachine() const
Definition ELFYAML.cpp:35
std::optional< DWARFYAML::Data > DWARF
Definition ELFYAML.h:699
const SectionHeaderTable & getSectionHeaderTable() const
Definition ELFYAML.h:709
FileHeader Header
Definition ELFYAML.h:686
std::vector< std::unique_ptr< Chunk > > Chunks
Definition ELFYAML.h:691
ELF_ELFOSABI getOSAbi() const
Definition ELFYAML.cpp:33
std::vector< ProgramHeader > ProgramHeaders
Definition ELFYAML.h:687
std::optional< std::vector< Symbol > > Symbols
Definition ELFYAML.h:697
std::vector< Section * > getSections()
Definition ELFYAML.h:701
std::optional< llvm::yaml::Hex64 > Align
Definition ELFYAML.h:674
llvm::yaml::Hex64 PAddr
Definition ELFYAML.h:673
std::optional< llvm::yaml::Hex64 > Offset
Definition ELFYAML.h:677
llvm::yaml::Hex64 VAddr
Definition ELFYAML.h:672
std::optional< llvm::yaml::Hex64 > MemSize
Definition ELFYAML.h:676
std::optional< StringRef > FirstSec
Definition ELFYAML.h:678
std::optional< StringRef > LastSec
Definition ELFYAML.h:679
std::optional< llvm::yaml::Hex64 > FileSize
Definition ELFYAML.h:675
std::vector< Chunk * > Chunks
Definition ELFYAML.h:682
static bool classof(const Chunk *S)
Definition ELFYAML.h:355
std::optional< llvm::yaml::Hex64 > Info
Definition ELFYAML.h:351
std::optional< std::vector< uint8_t > > ContentBuf
Definition ELFYAML.h:360
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:592
std::optional< std::vector< Relocation > > Relocations
Definition ELFYAML.h:587
static bool classof(const Chunk *S)
Definition ELFYAML.h:596
std::optional< StringRef > Symbol
Definition ELFYAML.h:583
llvm::yaml::Hex64 Offset
Definition ELFYAML.h:580
static bool classof(const Chunk *S)
Definition ELFYAML.h:610
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:606
std::optional< std::vector< llvm::yaml::Hex64 > > Entries
Definition ELFYAML.h:602
std::optional< std::vector< SectionHeader > > Excluded
Definition ELFYAML.h:289
static constexpr StringRef TypeStr
Definition ELFYAML.h:302
std::optional< bool > NoHeaders
Definition ELFYAML.h:290
static bool classof(const Chunk *S)
Definition ELFYAML.h:284
SectionHeaderTable(bool IsImplicit)
Definition ELFYAML.h:281
size_t getNumHeaders(size_t SectionsNum) const
Definition ELFYAML.h:292
std::optional< std::vector< SectionHeader > > Sections
Definition ELFYAML.h:288
std::optional< llvm::yaml::Hex64 > Address
Definition ELFYAML.h:216
std::optional< StringRef > Link
Definition ELFYAML.h:217
Section(ChunkKind Kind, bool IsImplicit=false)
Definition ELFYAML.h:227
std::optional< llvm::yaml::Hex64 > Size
Definition ELFYAML.h:222
static bool classof(const Chunk *S)
Definition ELFYAML.h:229
std::optional< llvm::yaml::Hex64 > ShAddrAlign
Definition ELFYAML.h:244
llvm::yaml::Hex64 AddressAlign
Definition ELFYAML.h:218
unsigned OriginalSecNdx
Definition ELFYAML.h:225
std::optional< ELF_SHF > Flags
Definition ELFYAML.h:215
std::optional< ELF_SHT > ShType
Definition ELFYAML.h:265
std::optional< llvm::yaml::Hex64 > ShOffset
Definition ELFYAML.h:252
virtual std::vector< std::pair< StringRef, bool > > getEntries() const
Definition ELFYAML.h:236
std::optional< llvm::yaml::Hex64 > ShFlags
Definition ELFYAML.h:259
std::optional< llvm::yaml::Hex64 > ShName
Definition ELFYAML.h:248
std::optional< yaml::BinaryRef > Content
Definition ELFYAML.h:221
std::optional< llvm::yaml::Hex64 > EntSize
Definition ELFYAML.h:219
std::optional< llvm::yaml::Hex64 > ShSize
Definition ELFYAML.h:256
llvm::yaml::Hex64 Size
Definition ELFYAML.h:162
llvm::yaml::Hex64 Address
Definition ELFYAML.h:161
static bool classof(const Chunk *S)
Definition ELFYAML.h:329
static bool nameMatches(StringRef Name)
Definition ELFYAML.h:333
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:325
std::optional< std::vector< StackSizeEntry > > Entries
Definition ELFYAML.h:321
std::optional< ELF_SHN > Index
Definition ELFYAML.h:142
std::optional< StringRef > Section
Definition ELFYAML.h:141
std::optional< uint8_t > Other
Definition ELFYAML.h:146
std::optional< uint32_t > StName
Definition ELFYAML.h:148
std::optional< llvm::yaml::Hex64 > Value
Definition ELFYAML.h:144
std::optional< llvm::yaml::Hex64 > Size
Definition ELFYAML.h:145
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:620
static bool classof(const Chunk *S)
Definition ELFYAML.h:624
std::optional< std::vector< uint32_t > > Entries
Definition ELFYAML.h:616
std::optional< std::vector< uint16_t > > Entries
Definition ELFYAML.h:531
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:535
static bool classof(const Chunk *S)
Definition ELFYAML.h:539
std::optional< uint16_t > Flags
Definition ELFYAML.h:544
std::optional< uint16_t > VDAux
Definition ELFYAML.h:547
std::vector< StringRef > VerNames
Definition ELFYAML.h:548
std::optional< uint16_t > VersionNdx
Definition ELFYAML.h:545
std::optional< uint16_t > Version
Definition ELFYAML.h:543
std::optional< uint32_t > Hash
Definition ELFYAML.h:546
static bool classof(const Chunk *S)
Definition ELFYAML.h:561
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:557
std::optional< llvm::yaml::Hex64 > Info
Definition ELFYAML.h:553
std::optional< std::vector< VerdefEntry > > Entries
Definition ELFYAML.h:552
std::vector< VernauxEntry > AuxV
Definition ELFYAML.h:447
std::vector< std::pair< StringRef, bool > > getEntries() const override
Definition ELFYAML.h:456
std::optional< llvm::yaml::Hex64 > Info
Definition ELFYAML.h:452
static bool classof(const Chunk *S)
Definition ELFYAML.h:460
std::optional< std::vector< VerneedEntry > > VerneedV
Definition ELFYAML.h:451
static void mapping(IO &IO, ELFYAML::ARMIndexTableEntry &E)
Definition ELFYAML.cpp:1896
static void mapping(IO &IO, ELFYAML::CallGraphEntryWeight &E)
Definition ELFYAML.cpp:1936
static void mapping(IO &IO, ELFYAML::DynamicEntry &Rel)
Definition ELFYAML.cpp:1827
static void mapping(IO &IO, ELFYAML::FileHeader &FileHdr)
Definition ELFYAML.cpp:1109
static void mapping(IO &IO, ELFYAML::GnuHashHeader &Rel)
Definition ELFYAML.cpp:1818
static void mapping(IO &IO, ELFYAML::LinkerOption &Sym)
Definition ELFYAML.cpp:1929
static void mapping(IO &IO, ELFYAML::NoteEntry &N)
Definition ELFYAML.cpp:1835
static void mapping(IO &IO, ELFYAML::Object &Object)
Definition ELFYAML.cpp:1910
static std::string validate(IO &IO, ELFYAML::ProgramHeader &FileHdr)
Definition ELFYAML.cpp:1147
static void mapping(IO &IO, ELFYAML::ProgramHeader &FileHdr)
Definition ELFYAML.cpp:1133
static void mapping(IO &IO, ELFYAML::Relocation &Rel)
Definition ELFYAML.cpp:1874
static void mapping(IO &IO, ELFYAML::SectionHeader &SHdr)
Definition ELFYAML.cpp:1104
static void mapping(IO &IO, ELFYAML::SectionOrType &sectionOrType)
Definition ELFYAML.cpp:1511
static void mapping(IO &IO, ELFYAML::StackSizeEntry &Rel)
Definition ELFYAML.cpp:1811
static void mapping(IO &IO, ELFYAML::Symbol &Symbol)
Definition ELFYAML.cpp:1320
static std::string validate(IO &IO, ELFYAML::Symbol &Symbol)
Definition ELFYAML.cpp:1340
static void mapping(IO &IO, ELFYAML::VerdefEntry &E)
Definition ELFYAML.cpp:1843
static void mapping(IO &IO, ELFYAML::VernauxEntry &E)
Definition ELFYAML.cpp:1864
static void mapping(IO &IO, ELFYAML::VerneedEntry &E)
Definition ELFYAML.cpp:1855
static std::string validate(IO &io, std::unique_ptr< ELFYAML::Chunk > &C)
Definition ELFYAML.cpp:1714
static void mapping(IO &IO, std::unique_ptr< ELFYAML::Chunk > &C)
Definition ELFYAML.cpp:1556
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
Definition YAMLTraits.h:63
static void bitset(IO &IO, ELFYAML::ELF_EF &Value)
Definition ELFYAML.cpp:420
static void bitset(IO &IO, ELFYAML::ELF_PF &Value)
Definition ELFYAML.cpp:727
static void bitset(IO &IO, ELFYAML::ELF_SHF &Value)
Definition ELFYAML.cpp:735
static void bitset(IO &IO, ELFYAML::MIPS_AFL_ASE &Value)
Definition ELFYAML.cpp:1076
static void bitset(IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value)
Definition ELFYAML.cpp:1097
This class should be specialized by any integer type that is a union of bit values and the YAML repre...
Definition YAMLTraits.h:124
static void enumeration(IO &IO, ELFYAML::ELF_DYNTAG &Value)
Definition ELFYAML.cpp:932
static void enumeration(IO &IO, ELFYAML::ELF_ELFCLASS &Value)
Definition ELFYAML.cpp:366
static void enumeration(IO &IO, ELFYAML::ELF_ELFDATA &Value)
Definition ELFYAML.cpp:376
static void enumeration(IO &IO, ELFYAML::ELF_ELFOSABI &Value)
Definition ELFYAML.cpp:387
static void enumeration(IO &IO, ELFYAML::ELF_EM &Value)
Definition ELFYAML.cpp:195
static void enumeration(IO &IO, ELFYAML::ELF_ET &Value)
Definition ELFYAML.cpp:44
static void enumeration(IO &IO, ELFYAML::ELF_NT &Value)
Definition ELFYAML.cpp:76
static void enumeration(IO &IO, ELFYAML::ELF_PT &Value)
Definition ELFYAML.cpp:56
static void enumeration(IO &IO, ELFYAML::ELF_REL &Value)
Definition ELFYAML.cpp:860
static void enumeration(IO &IO, ELFYAML::ELF_RSS &Value)
Definition ELFYAML.cpp:850
static void enumeration(IO &IO, ELFYAML::ELF_SHN &Value)
Definition ELFYAML.cpp:789
static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value)
Definition ELFYAML.cpp:641
static void enumeration(IO &IO, ELFYAML::ELF_STB &Value)
Definition ELFYAML.cpp:823
static void enumeration(IO &IO, ELFYAML::ELF_STT &Value)
Definition ELFYAML.cpp:834
static void enumeration(IO &IO, ELFYAML::MIPS_ABI_FP &Value)
Definition ELFYAML.cpp:1024
static void enumeration(IO &IO, ELFYAML::MIPS_AFL_EXT &Value)
Definition ELFYAML.cpp:1038
static void enumeration(IO &IO, ELFYAML::MIPS_AFL_REG &Value)
Definition ELFYAML.cpp:1014
static void enumeration(IO &IO, ELFYAML::MIPS_ISA &Value)
Definition ELFYAML.cpp:1064
This class should be specialized by any integral type that converts to/from a YAML scalar where there...
Definition YAMLTraits.h:108
static void output(const ELFYAML::YAMLIntUInt &Val, void *Ctx, raw_ostream &Out)
Definition ELFYAML.cpp:1288
static StringRef input(StringRef Scalar, void *Ctx, ELFYAML::YAMLIntUInt &Val)
Definition ELFYAML.cpp:1293
static QuotingType mustQuote(StringRef)
Definition ELFYAML.h:750
This class should be specialized by type that requires custom conversion to/from a yaml scalar.
Definition YAMLTraits.h:150