LLVM  10.0.0svn
ELFYAML.cpp
Go to the documentation of this file.
1 //===- ELFYAML.cpp - ELF YAMLIO implementation ----------------------------===//
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 // This file defines classes for handling the YAML representation of ELF.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/ADT/MapVector.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/BinaryFormat/ELF.h"
17 #include "llvm/Support/Casting.h"
21 #include "llvm/Support/WithColor.h"
22 #include <cassert>
23 #include <cstdint>
24 
25 namespace llvm {
26 
27 ELFYAML::Section::~Section() = default;
28 
29 namespace yaml {
30 
32  IO &IO, ELFYAML::ELF_ET &Value) {
33 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
34  ECase(ET_NONE);
35  ECase(ET_REL);
36  ECase(ET_EXEC);
37  ECase(ET_DYN);
38  ECase(ET_CORE);
39 #undef ECase
40  IO.enumFallback<Hex16>(Value);
41 }
42 
44  IO &IO, ELFYAML::ELF_PT &Value) {
45 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
46  ECase(PT_NULL);
47  ECase(PT_LOAD);
50  ECase(PT_NOTE);
51  ECase(PT_SHLIB);
52  ECase(PT_PHDR);
53  ECase(PT_TLS);
57 #undef ECase
58  IO.enumFallback<Hex32>(Value);
59 }
60 
62  IO &IO, ELFYAML::ELF_EM &Value) {
63 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
64  ECase(EM_NONE);
65  ECase(EM_M32);
66  ECase(EM_SPARC);
67  ECase(EM_386);
68  ECase(EM_68K);
69  ECase(EM_88K);
70  ECase(EM_IAMCU);
71  ECase(EM_860);
72  ECase(EM_MIPS);
73  ECase(EM_S370);
78  ECase(EM_960);
79  ECase(EM_PPC);
80  ECase(EM_PPC64);
81  ECase(EM_S390);
82  ECase(EM_SPU);
83  ECase(EM_V800);
84  ECase(EM_FR20);
85  ECase(EM_RH32);
86  ECase(EM_RCE);
87  ECase(EM_ARM);
88  ECase(EM_ALPHA);
89  ECase(EM_SH);
92  ECase(EM_ARC);
95  ECase(EM_H8S);
97  ECase(EM_IA_64);
100  ECase(EM_68HC12);
101  ECase(EM_MMA);
102  ECase(EM_PCP);
103  ECase(EM_NCPU);
104  ECase(EM_NDR1);
106  ECase(EM_ME16);
107  ECase(EM_ST100);
108  ECase(EM_TINYJ);
109  ECase(EM_X86_64);
110  ECase(EM_PDSP);
111  ECase(EM_PDP10);
112  ECase(EM_PDP11);
113  ECase(EM_FX66);
114  ECase(EM_ST9PLUS);
115  ECase(EM_ST7);
116  ECase(EM_68HC16);
117  ECase(EM_68HC11);
118  ECase(EM_68HC08);
119  ECase(EM_68HC05);
120  ECase(EM_SVX);
121  ECase(EM_ST19);
122  ECase(EM_VAX);
123  ECase(EM_CRIS);
124  ECase(EM_JAVELIN);
126  ECase(EM_ZSP);
127  ECase(EM_MMIX);
128  ECase(EM_HUANY);
129  ECase(EM_PRISM);
130  ECase(EM_AVR);
131  ECase(EM_FR30);
132  ECase(EM_D10V);
133  ECase(EM_D30V);
134  ECase(EM_V850);
135  ECase(EM_M32R);
136  ECase(EM_MN10300);
137  ECase(EM_MN10200);
138  ECase(EM_PJ);
141  ECase(EM_XTENSA);
143  ECase(EM_TMM_GPP);
144  ECase(EM_NS32K);
145  ECase(EM_TPC);
146  ECase(EM_SNP1K);
147  ECase(EM_ST200);
148  ECase(EM_IP2K);
149  ECase(EM_MAX);
150  ECase(EM_CR);
151  ECase(EM_F2MC16);
152  ECase(EM_MSP430);
154  ECase(EM_SE_C33);
155  ECase(EM_SEP);
156  ECase(EM_ARCA);
157  ECase(EM_UNICORE);
158  ECase(EM_EXCESS);
159  ECase(EM_DXP);
161  ECase(EM_CRX);
162  ECase(EM_XGATE);
163  ECase(EM_C166);
164  ECase(EM_M16C);
166  ECase(EM_CE);
167  ECase(EM_M32C);
168  ECase(EM_TSK3000);
169  ECase(EM_RS08);
170  ECase(EM_SHARC);
171  ECase(EM_ECOG2);
172  ECase(EM_SCORE7);
173  ECase(EM_DSP24);
176  ECase(EM_SE_C17);
182  ECase(EM_R32C);
184  ECase(EM_HEXAGON);
185  ECase(EM_8051);
186  ECase(EM_STXP7X);
187  ECase(EM_NDS32);
188  ECase(EM_ECOG1);
189  ECase(EM_ECOG1X);
190  ECase(EM_MAXQ30);
191  ECase(EM_XIMO16);
192  ECase(EM_MANIK);
193  ECase(EM_CRAYNV2);
194  ECase(EM_RX);
195  ECase(EM_METAG);
197  ECase(EM_ECOG16);
198  ECase(EM_CR16);
199  ECase(EM_ETPU);
200  ECase(EM_SLE9X);
201  ECase(EM_L10M);
202  ECase(EM_K10M);
203  ECase(EM_AARCH64);
204  ECase(EM_AVR32);
205  ECase(EM_STM8);
206  ECase(EM_TILE64);
207  ECase(EM_TILEPRO);
208  ECase(EM_CUDA);
209  ECase(EM_TILEGX);
214  ECase(EM_OPEN8);
215  ECase(EM_RL78);
217  ECase(EM_78KOR);
218  ECase(EM_56800EX);
219  ECase(EM_AMDGPU);
220  ECase(EM_RISCV);
221  ECase(EM_LANAI);
222  ECase(EM_BPF);
223 #undef ECase
224  IO.enumFallback<Hex16>(Value);
225 }
226 
228  IO &IO, ELFYAML::ELF_ELFCLASS &Value) {
229 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
230  // Since the semantics of ELFCLASSNONE is "invalid", just don't accept it
231  // here.
232  ECase(ELFCLASS32);
233  ECase(ELFCLASS64);
234 #undef ECase
235 }
236 
238  IO &IO, ELFYAML::ELF_ELFDATA &Value) {
239 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
240  // ELFDATANONE is an invalid data encoding, but we accept it because
241  // we want to be able to produce invalid binaries for the tests.
245 #undef ECase
246 }
247 
249  IO &IO, ELFYAML::ELF_ELFOSABI &Value) {
250 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
275 #undef ECase
276 }
277 
279  ELFYAML::ELF_EF &Value) {
280  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
281  assert(Object && "The IO context is not initialized");
282 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
283 #define BCaseMask(X, M) IO.maskedBitSetCase(Value, #X, ELF::X, ELF::M)
284  switch (Object->Header.Machine) {
285  case ELF::EM_ARM:
294  break;
295  case ELF::EM_MIPS:
339  break;
340  case ELF::EM_HEXAGON:
357  break;
358  case ELF::EM_AVR:
376  break;
377  case ELF::EM_RISCV:
384  break;
385  case ELF::EM_AMDGPU:
425  break;
426  case ELF::EM_X86_64:
427  break;
428  default:
429  llvm_unreachable("Unsupported architecture");
430  }
431 #undef BCase
432 #undef BCaseMask
433 }
434 
436  IO &IO, ELFYAML::ELF_SHT &Value) {
437  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
438  assert(Object && "The IO context is not initialized");
439 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
440  ECase(SHT_NULL);
442  ECase(SHT_SYMTAB);
443  // FIXME: Issue a diagnostic with this information.
444  ECase(SHT_STRTAB);
445  ECase(SHT_RELA);
446  ECase(SHT_HASH);
448  ECase(SHT_NOTE);
449  ECase(SHT_NOBITS);
450  ECase(SHT_REL);
451  ECase(SHT_SHLIB);
452  ECase(SHT_DYNSYM);
456  ECase(SHT_GROUP);
458  ECase(SHT_RELR);
475  switch (Object->Header.Machine) {
476  case ELF::EM_ARM:
482  break;
483  case ELF::EM_HEXAGON:
485  break;
486  case ELF::EM_X86_64:
488  break;
489  case ELF::EM_MIPS:
494  break;
495  default:
496  // Nothing to do.
497  break;
498  }
499 #undef ECase
500  IO.enumFallback<Hex32>(Value);
501 }
502 
504  ELFYAML::ELF_PF &Value) {
505 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
506  BCase(PF_X);
507  BCase(PF_W);
508  BCase(PF_R);
509 }
510 
512  ELFYAML::ELF_SHF &Value) {
513  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
514 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
515  BCase(SHF_WRITE);
516  BCase(SHF_ALLOC);
519  BCase(SHF_MERGE);
524  BCase(SHF_GROUP);
525  BCase(SHF_TLS);
527  switch (Object->Header.Machine) {
528  case ELF::EM_ARM:
530  break;
531  case ELF::EM_HEXAGON:
533  break;
534  case ELF::EM_MIPS:
543  break;
544  case ELF::EM_X86_64:
546  break;
547  default:
548  // Nothing to do.
549  break;
550  }
551 #undef BCase
552 }
553 
555  IO &IO, ELFYAML::ELF_SHN &Value) {
556 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
557  ECase(SHN_UNDEF);
559  ECase(SHN_LOPROC);
560  ECase(SHN_HIPROC);
561  ECase(SHN_LOOS);
562  ECase(SHN_HIOS);
563  ECase(SHN_ABS);
564  ECase(SHN_COMMON);
565  ECase(SHN_XINDEX);
573 #undef ECase
574  IO.enumFallback<Hex16>(Value);
575 }
576 
578  IO &IO, ELFYAML::ELF_STB &Value) {
579 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
580  ECase(STB_LOCAL);
581  ECase(STB_GLOBAL);
582  ECase(STB_WEAK);
584 #undef ECase
585  IO.enumFallback<Hex8>(Value);
586 }
587 
589  IO &IO, ELFYAML::ELF_STT &Value) {
590 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
591  ECase(STT_NOTYPE);
592  ECase(STT_OBJECT);
593  ECase(STT_FUNC);
595  ECase(STT_FILE);
596  ECase(STT_COMMON);
597  ECase(STT_TLS);
599 #undef ECase
600  IO.enumFallback<Hex8>(Value);
601 }
602 
603 
605  IO &IO, ELFYAML::ELF_RSS &Value) {
606 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
607  ECase(RSS_UNDEF);
608  ECase(RSS_GP);
609  ECase(RSS_GP0);
610  ECase(RSS_LOC);
611 #undef ECase
612 }
613 
615  IO &IO, ELFYAML::ELF_REL &Value) {
616  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
617  assert(Object && "The IO context is not initialized");
618 #define ELF_RELOC(X, Y) IO.enumCase(Value, #X, ELF::X);
619  switch (Object->Header.Machine) {
620  case ELF::EM_X86_64:
621 #include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
622  break;
623  case ELF::EM_MIPS:
624 #include "llvm/BinaryFormat/ELFRelocs/Mips.def"
625  break;
626  case ELF::EM_HEXAGON:
627 #include "llvm/BinaryFormat/ELFRelocs/Hexagon.def"
628  break;
629  case ELF::EM_386:
630  case ELF::EM_IAMCU:
631 #include "llvm/BinaryFormat/ELFRelocs/i386.def"
632  break;
633  case ELF::EM_AARCH64:
634 #include "llvm/BinaryFormat/ELFRelocs/AArch64.def"
635  break;
636  case ELF::EM_ARM:
637 #include "llvm/BinaryFormat/ELFRelocs/ARM.def"
638  break;
639  case ELF::EM_ARC:
640 #include "llvm/BinaryFormat/ELFRelocs/ARC.def"
641  break;
642  case ELF::EM_RISCV:
643 #include "llvm/BinaryFormat/ELFRelocs/RISCV.def"
644  break;
645  case ELF::EM_LANAI:
646 #include "llvm/BinaryFormat/ELFRelocs/Lanai.def"
647  break;
648  case ELF::EM_AMDGPU:
649 #include "llvm/BinaryFormat/ELFRelocs/AMDGPU.def"
650  break;
651  case ELF::EM_BPF:
652 #include "llvm/BinaryFormat/ELFRelocs/BPF.def"
653  break;
654  case ELF::EM_PPC64:
655 #include "llvm/BinaryFormat/ELFRelocs/PowerPC64.def"
656  break;
657  default:
658  // Nothing to do.
659  break;
660  }
661 #undef ELF_RELOC
662  IO.enumFallback<Hex32>(Value);
663 }
664 
666  IO &IO, ELFYAML::ELF_DYNTAG &Value) {
667  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
668  assert(Object && "The IO context is not initialized");
669 
670 // Disable architecture specific tags by default. We might enable them below.
671 #define AARCH64_DYNAMIC_TAG(name, value)
672 #define MIPS_DYNAMIC_TAG(name, value)
673 #define HEXAGON_DYNAMIC_TAG(name, value)
674 #define PPC_DYNAMIC_TAG(name, value)
675 #define PPC64_DYNAMIC_TAG(name, value)
676 // Ignore marker tags such as DT_HIOS (maps to DT_VERNEEDNUM), etc.
677 #define DYNAMIC_TAG_MARKER(name, value)
678 
679 #define STRINGIFY(X) (#X)
680 #define DYNAMIC_TAG(X, Y) IO.enumCase(Value, STRINGIFY(DT_##X), ELF::DT_##X);
681  switch (Object->Header.Machine) {
682  case ELF::EM_AARCH64:
683 #undef AARCH64_DYNAMIC_TAG
684 #define AARCH64_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
685 #include "llvm/BinaryFormat/DynamicTags.def"
686 #undef AARCH64_DYNAMIC_TAG
687 #define AARCH64_DYNAMIC_TAG(name, value)
688  break;
689  case ELF::EM_MIPS:
690 #undef MIPS_DYNAMIC_TAG
691 #define MIPS_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
692 #include "llvm/BinaryFormat/DynamicTags.def"
693 #undef MIPS_DYNAMIC_TAG
694 #define MIPS_DYNAMIC_TAG(name, value)
695  break;
696  case ELF::EM_HEXAGON:
697 #undef HEXAGON_DYNAMIC_TAG
698 #define HEXAGON_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
699 #include "llvm/BinaryFormat/DynamicTags.def"
700 #undef HEXAGON_DYNAMIC_TAG
701 #define HEXAGON_DYNAMIC_TAG(name, value)
702  break;
703  case ELF::EM_PPC:
704 #undef PPC_DYNAMIC_TAG
705 #define PPC_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
706 #include "llvm/BinaryFormat/DynamicTags.def"
707 #undef PPC_DYNAMIC_TAG
708 #define PPC_DYNAMIC_TAG(name, value)
709  break;
710  case ELF::EM_PPC64:
711 #undef PPC64_DYNAMIC_TAG
712 #define PPC64_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
713 #include "llvm/BinaryFormat/DynamicTags.def"
714 #undef PPC64_DYNAMIC_TAG
715 #define PPC64_DYNAMIC_TAG(name, value)
716  break;
717  default:
718 #include "llvm/BinaryFormat/DynamicTags.def"
719  break;
720  }
721 #undef AARCH64_DYNAMIC_TAG
722 #undef MIPS_DYNAMIC_TAG
723 #undef HEXAGON_DYNAMIC_TAG
724 #undef PPC_DYNAMIC_TAG
725 #undef PPC64_DYNAMIC_TAG
726 #undef DYNAMIC_TAG_MARKER
727 #undef STRINGIFY
728 #undef DYNAMIC_TAG
729 
730  IO.enumFallback<Hex64>(Value);
731 }
732 
734  IO &IO, ELFYAML::MIPS_AFL_REG &Value) {
735 #define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X)
736  ECase(REG_NONE);
737  ECase(REG_32);
738  ECase(REG_64);
739  ECase(REG_128);
740 #undef ECase
741 }
742 
744  IO &IO, ELFYAML::MIPS_ABI_FP &Value) {
745 #define ECase(X) IO.enumCase(Value, #X, Mips::Val_GNU_MIPS_ABI_##X)
746  ECase(FP_ANY);
747  ECase(FP_DOUBLE);
748  ECase(FP_SINGLE);
749  ECase(FP_SOFT);
750  ECase(FP_OLD_64);
751  ECase(FP_XX);
752  ECase(FP_64);
753  ECase(FP_64A);
754 #undef ECase
755 }
756 
758  IO &IO, ELFYAML::MIPS_AFL_EXT &Value) {
759 #define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X)
760  ECase(EXT_NONE);
761  ECase(EXT_XLR);
762  ECase(EXT_OCTEON2);
763  ECase(EXT_OCTEONP);
764  ECase(EXT_LOONGSON_3A);
765  ECase(EXT_OCTEON);
766  ECase(EXT_5900);
767  ECase(EXT_4650);
768  ECase(EXT_4010);
769  ECase(EXT_4100);
770  ECase(EXT_3900);
771  ECase(EXT_10000);
772  ECase(EXT_SB1);
773  ECase(EXT_4111);
774  ECase(EXT_4120);
775  ECase(EXT_5400);
776  ECase(EXT_5500);
777  ECase(EXT_LOONGSON_2E);
778  ECase(EXT_LOONGSON_2F);
779  ECase(EXT_OCTEON3);
780 #undef ECase
781 }
782 
784  IO &IO, ELFYAML::MIPS_ISA &Value) {
785  IO.enumCase(Value, "MIPS1", 1);
786  IO.enumCase(Value, "MIPS2", 2);
787  IO.enumCase(Value, "MIPS3", 3);
788  IO.enumCase(Value, "MIPS4", 4);
789  IO.enumCase(Value, "MIPS5", 5);
790  IO.enumCase(Value, "MIPS32", 32);
791  IO.enumCase(Value, "MIPS64", 64);
792 }
793 
795  IO &IO, ELFYAML::MIPS_AFL_ASE &Value) {
796 #define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_ASE_##X)
797  BCase(DSP);
798  BCase(DSPR2);
799  BCase(EVA);
800  BCase(MCU);
801  BCase(MDMX);
802  BCase(MIPS3D);
803  BCase(MT);
804  BCase(SMARTMIPS);
805  BCase(VIRT);
806  BCase(MSA);
807  BCase(MIPS16);
808  BCase(MICROMIPS);
809  BCase(XPA);
810 #undef BCase
811 }
812 
814  IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value) {
815 #define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_FLAGS1_##X)
816  BCase(ODDSPREG);
817 #undef BCase
818 }
819 
821  ELFYAML::FileHeader &FileHdr) {
822  IO.mapRequired("Class", FileHdr.Class);
823  IO.mapRequired("Data", FileHdr.Data);
824  IO.mapOptional("OSABI", FileHdr.OSABI, ELFYAML::ELF_ELFOSABI(0));
825  IO.mapOptional("ABIVersion", FileHdr.ABIVersion, Hex8(0));
826  IO.mapRequired("Type", FileHdr.Type);
827  IO.mapRequired("Machine", FileHdr.Machine);
828  IO.mapOptional("Flags", FileHdr.Flags, ELFYAML::ELF_EF(0));
829  IO.mapOptional("Entry", FileHdr.Entry, Hex64(0));
830 
831  IO.mapOptional("SHEntSize", FileHdr.SHEntSize);
832  IO.mapOptional("SHOff", FileHdr.SHOff);
833  IO.mapOptional("SHNum", FileHdr.SHNum);
834  IO.mapOptional("SHStrNdx", FileHdr.SHStrNdx);
835 }
836 
838  IO &IO, ELFYAML::ProgramHeader &Phdr) {
839  IO.mapRequired("Type", Phdr.Type);
840  IO.mapOptional("Flags", Phdr.Flags, ELFYAML::ELF_PF(0));
841  IO.mapOptional("Sections", Phdr.Sections);
842  IO.mapOptional("VAddr", Phdr.VAddr, Hex64(0));
843  IO.mapOptional("PAddr", Phdr.PAddr, Hex64(0));
844  IO.mapOptional("Align", Phdr.Align);
845  IO.mapOptional("FileSize", Phdr.FileSize);
846  IO.mapOptional("MemSize", Phdr.MemSize);
847  IO.mapOptional("Offset", Phdr.Offset);
848 }
849 
850 LLVM_YAML_STRONG_TYPEDEF(StringRef, StOtherPiece)
851 
852 template <> struct ScalarTraits<StOtherPiece> {
853  static void output(const StOtherPiece &Val, void *, raw_ostream &Out) {
854  Out << Val;
855  }
856  static StringRef input(StringRef Scalar, void *, StOtherPiece &Val) {
857  Val = Scalar;
858  return {};
859  }
860  static QuotingType mustQuote(StringRef) { return QuotingType::None; }
861 };
862 template <> struct SequenceElementTraits<StOtherPiece> {
863  static const bool flow = true;
864 };
865 
866 namespace {
867 
868 struct NormalizedOther {
869  NormalizedOther(IO &IO) : YamlIO(IO) {}
870  NormalizedOther(IO &IO, Optional<uint8_t> Original) : YamlIO(IO) {
871  assert(Original && "This constructor is only used for outputting YAML and "
872  "assumes a non-empty Original");
873  std::vector<StOtherPiece> Ret;
874  const auto *Object = static_cast<ELFYAML::Object *>(YamlIO.getContext());
875  for (std::pair<StringRef, uint8_t> &P :
876  getFlags(Object->Header.Machine).takeVector()) {
877  uint8_t FlagValue = P.second;
878  if ((*Original & FlagValue) != FlagValue)
879  continue;
880  *Original &= ~FlagValue;
881  Ret.push_back({P.first});
882  }
883 
884  if (*Original != 0) {
885  UnknownFlagsHolder = std::to_string(*Original);
886  Ret.push_back({UnknownFlagsHolder});
887  }
888 
889  if (!Ret.empty())
890  Other = std::move(Ret);
891  }
892 
893  uint8_t toValue(StringRef Name) {
894  const auto *Object = static_cast<ELFYAML::Object *>(YamlIO.getContext());
895  MapVector<StringRef, uint8_t> Flags = getFlags(Object->Header.Machine);
896 
897  auto It = Flags.find(Name);
898  if (It != Flags.end())
899  return It->second;
900 
901  uint8_t Val;
902  if (to_integer(Name, Val))
903  return Val;
904 
905  YamlIO.setError("an unknown value is used for symbol's 'Other' field: " +
906  Name);
907  return 0;
908  }
909 
910  Optional<uint8_t> denormalize(IO &) {
911  if (!Other)
912  return None;
913  uint8_t Ret = 0;
914  for (StOtherPiece &Val : *Other)
915  Ret |= toValue(Val);
916  return Ret;
917  }
918 
919  // st_other field is used to encode symbol visibility and platform-dependent
920  // flags and values. This method returns a name to value map that is used for
921  // parsing and encoding this field.
922  MapVector<StringRef, uint8_t> getFlags(unsigned EMachine) {
924  // STV_* values are just enumeration values. We add them in a reversed order
925  // because when we convert the st_other to named constants when printing
926  // YAML we want to use a maximum number of bits on each step:
927  // when we have st_other == 3, we want to print it as STV_PROTECTED (3), but
928  // not as STV_HIDDEN (2) + STV_INTERNAL (1).
929  Map["STV_PROTECTED"] = ELF::STV_PROTECTED;
930  Map["STV_HIDDEN"] = ELF::STV_HIDDEN;
931  Map["STV_INTERNAL"] = ELF::STV_INTERNAL;
932  // STV_DEFAULT is used to represent the default visibility and has a value
933  // 0. We want to be able to read it from YAML documents, but there is no
934  // reason to print it.
935  if (!YamlIO.outputting())
936  Map["STV_DEFAULT"] = ELF::STV_DEFAULT;
937 
938  // MIPS is not consistent. All of the STO_MIPS_* values are bit flags,
939  // except STO_MIPS_MIPS16 which overlaps them. It should be checked and
940  // consumed first when we print the output, because we do not want to print
941  // any other flags that have the same bits instead.
942  if (EMachine == ELF::EM_MIPS) {
943  Map["STO_MIPS_MIPS16"] = ELF::STO_MIPS_MIPS16;
944  Map["STO_MIPS_MICROMIPS"] = ELF::STO_MIPS_MICROMIPS;
945  Map["STO_MIPS_PIC"] = ELF::STO_MIPS_PIC;
946  Map["STO_MIPS_PLT"] = ELF::STO_MIPS_PLT;
947  Map["STO_MIPS_OPTIONAL"] = ELF::STO_MIPS_OPTIONAL;
948  }
949  return Map;
950  }
951 
952  IO &YamlIO;
953  Optional<std::vector<StOtherPiece>> Other;
954  std::string UnknownFlagsHolder;
955 };
956 
957 } // end anonymous namespace
958 
960  IO.mapOptional("Name", Symbol.Name, StringRef());
961  IO.mapOptional("NameIndex", Symbol.NameIndex);
962  IO.mapOptional("Type", Symbol.Type, ELFYAML::ELF_STT(0));
963  IO.mapOptional("Section", Symbol.Section, StringRef());
964  IO.mapOptional("Index", Symbol.Index);
965  IO.mapOptional("Binding", Symbol.Binding, ELFYAML::ELF_STB(0));
966  IO.mapOptional("Value", Symbol.Value, Hex64(0));
967  IO.mapOptional("Size", Symbol.Size, Hex64(0));
968 
969  // Symbol's Other field is a bit special. It is usually a field that
970  // represents st_other and holds the symbol visibility. However, on some
971  // platforms, it can contain bit fields and regular values, or even sometimes a
972  // crazy mix of them (see comments for NormalizedOther). Because of this, we
973  // need special handling.
974  MappingNormalization<NormalizedOther, Optional<uint8_t>> Keys(IO,
975  Symbol.Other);
976  IO.mapOptional("Other", Keys->Other);
977 }
978 
981  if (Symbol.Index && Symbol.Section.data())
982  return "Index and Section cannot both be specified for Symbol";
983  if (Symbol.NameIndex && !Symbol.Name.empty())
984  return "Name and NameIndex cannot both be specified for Symbol";
985  return StringRef();
986 }
987 
989  IO.mapOptional("Name", Section.Name, StringRef());
990  IO.mapRequired("Type", Section.Type);
991  IO.mapOptional("Flags", Section.Flags);
992  IO.mapOptional("Address", Section.Address, Hex64(0));
993  IO.mapOptional("Link", Section.Link, StringRef());
994  IO.mapOptional("AddressAlign", Section.AddressAlign, Hex64(0));
995  IO.mapOptional("EntSize", Section.EntSize);
996 
997  // obj2yaml does not dump these fields. They are expected to be empty when we
998  // are producing YAML, because yaml2obj sets appropriate values for them
999  // automatically when they are not explicitly defined.
1000  assert(!IO.outputting() ||
1001  (!Section.ShOffset.hasValue() && !Section.ShSize.hasValue()));
1002  IO.mapOptional("ShName", Section.ShName);
1003  IO.mapOptional("ShOffset", Section.ShOffset);
1004  IO.mapOptional("ShSize", Section.ShSize);
1005 }
1006 
1008  commonSectionMapping(IO, Section);
1009  IO.mapOptional("Entries", Section.Entries);
1010  IO.mapOptional("Content", Section.Content);
1011 }
1012 
1014  commonSectionMapping(IO, Section);
1015  IO.mapOptional("Content", Section.Content);
1016  IO.mapOptional("Size", Section.Size);
1017  IO.mapOptional("Info", Section.Info);
1018 }
1019 
1021  commonSectionMapping(IO, Section);
1022  IO.mapOptional("Content", Section.Content);
1023  IO.mapOptional("Size", Section.Size);
1024  IO.mapOptional("Entries", Section.Entries);
1025 }
1026 
1028  commonSectionMapping(IO, Section);
1029  IO.mapOptional("Content", Section.Content);
1030  IO.mapOptional("Bucket", Section.Bucket);
1031  IO.mapOptional("Chain", Section.Chain);
1032  IO.mapOptional("Size", Section.Size);
1033 }
1034 
1036  commonSectionMapping(IO, Section);
1037  IO.mapOptional("Size", Section.Size, Hex64(0));
1038 }
1039 
1041  commonSectionMapping(IO, Section);
1042  IO.mapRequired("Info", Section.Info);
1043  IO.mapRequired("Entries", Section.Entries);
1044 }
1045 
1047  commonSectionMapping(IO, Section);
1048  IO.mapRequired("Entries", Section.Entries);
1049 }
1050 
1052  commonSectionMapping(IO, Section);
1053  IO.mapRequired("Info", Section.Info);
1054  IO.mapRequired("Dependencies", Section.VerneedV);
1055 }
1056 
1058  commonSectionMapping(IO, Section);
1059  IO.mapOptional("Info", Section.RelocatableSec, StringRef());
1060  IO.mapOptional("Relocations", Section.Relocations);
1061 }
1062 
1063 static void groupSectionMapping(IO &IO, ELFYAML::Group &Group) {
1064  commonSectionMapping(IO, Group);
1065  IO.mapOptional("Info", Group.Signature, StringRef());
1066  IO.mapRequired("Members", Group.Members);
1067 }
1068 
1070  commonSectionMapping(IO, Section);
1071  IO.mapRequired("Entries", Section.Entries);
1072 }
1073 
1075  commonSectionMapping(IO, Section);
1076  IO.mapOptional("Content", Section.Content);
1077  IO.mapOptional("Size", Section.Size);
1078  IO.mapOptional("Symbols", Section.Symbols);
1079 }
1080 
1082  IO &IO, ELFYAML::SectionOrType &sectionOrType) {
1083  IO.mapRequired("SectionOrType", sectionOrType.sectionNameOrType);
1084 }
1085 
1087  IO &IO, ELFYAML::SectionName &sectionName) {
1088  IO.mapRequired("Section", sectionName.Section);
1089 }
1090 
1092  commonSectionMapping(IO, Section);
1093  IO.mapOptional("Version", Section.Version, Hex16(0));
1094  IO.mapRequired("ISA", Section.ISALevel);
1095  IO.mapOptional("ISARevision", Section.ISARevision, Hex8(0));
1096  IO.mapOptional("ISAExtension", Section.ISAExtension,
1097  ELFYAML::MIPS_AFL_EXT(Mips::AFL_EXT_NONE));
1098  IO.mapOptional("ASEs", Section.ASEs, ELFYAML::MIPS_AFL_ASE(0));
1099  IO.mapOptional("FpABI", Section.FpABI,
1100  ELFYAML::MIPS_ABI_FP(Mips::Val_GNU_MIPS_ABI_FP_ANY));
1101  IO.mapOptional("GPRSize", Section.GPRSize,
1102  ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
1103  IO.mapOptional("CPR1Size", Section.CPR1Size,
1104  ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
1105  IO.mapOptional("CPR2Size", Section.CPR2Size,
1106  ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
1107  IO.mapOptional("Flags1", Section.Flags1, ELFYAML::MIPS_AFL_FLAGS1(0));
1108  IO.mapOptional("Flags2", Section.Flags2, Hex32(0));
1109 }
1110 
1112  IO &IO, std::unique_ptr<ELFYAML::Section> &Section) {
1113  ELFYAML::ELF_SHT sectionType;
1114  if (IO.outputting())
1115  sectionType = Section->Type;
1116  else
1117  IO.mapRequired("Type", sectionType);
1118 
1119  switch (sectionType) {
1120  case ELF::SHT_DYNAMIC:
1121  if (!IO.outputting())
1122  Section.reset(new ELFYAML::DynamicSection());
1123  sectionMapping(IO, *cast<ELFYAML::DynamicSection>(Section.get()));
1124  break;
1125  case ELF::SHT_REL:
1126  case ELF::SHT_RELA:
1127  if (!IO.outputting())
1128  Section.reset(new ELFYAML::RelocationSection());
1129  sectionMapping(IO, *cast<ELFYAML::RelocationSection>(Section.get()));
1130  break;
1131  case ELF::SHT_GROUP:
1132  if (!IO.outputting())
1133  Section.reset(new ELFYAML::Group());
1134  groupSectionMapping(IO, *cast<ELFYAML::Group>(Section.get()));
1135  break;
1136  case ELF::SHT_NOBITS:
1137  if (!IO.outputting())
1138  Section.reset(new ELFYAML::NoBitsSection());
1139  sectionMapping(IO, *cast<ELFYAML::NoBitsSection>(Section.get()));
1140  break;
1141  case ELF::SHT_HASH:
1142  if (!IO.outputting())
1143  Section.reset(new ELFYAML::HashSection());
1144  sectionMapping(IO, *cast<ELFYAML::HashSection>(Section.get()));
1145  break;
1147  if (!IO.outputting())
1148  Section.reset(new ELFYAML::MipsABIFlags());
1149  sectionMapping(IO, *cast<ELFYAML::MipsABIFlags>(Section.get()));
1150  break;
1151  case ELF::SHT_GNU_verdef:
1152  if (!IO.outputting())
1153  Section.reset(new ELFYAML::VerdefSection());
1154  sectionMapping(IO, *cast<ELFYAML::VerdefSection>(Section.get()));
1155  break;
1156  case ELF::SHT_GNU_versym:
1157  if (!IO.outputting())
1158  Section.reset(new ELFYAML::SymverSection());
1159  sectionMapping(IO, *cast<ELFYAML::SymverSection>(Section.get()));
1160  break;
1161  case ELF::SHT_GNU_verneed:
1162  if (!IO.outputting())
1163  Section.reset(new ELFYAML::VerneedSection());
1164  sectionMapping(IO, *cast<ELFYAML::VerneedSection>(Section.get()));
1165  break;
1166  case ELF::SHT_SYMTAB_SHNDX:
1167  if (!IO.outputting())
1168  Section.reset(new ELFYAML::SymtabShndxSection());
1169  sectionMapping(IO, *cast<ELFYAML::SymtabShndxSection>(Section.get()));
1170  break;
1171  case ELF::SHT_LLVM_ADDRSIG:
1172  if (!IO.outputting())
1173  Section.reset(new ELFYAML::AddrsigSection());
1174  sectionMapping(IO, *cast<ELFYAML::AddrsigSection>(Section.get()));
1175  break;
1176  default:
1177  if (!IO.outputting()) {
1178  StringRef Name;
1179  IO.mapOptional("Name", Name, StringRef());
1180  Name = ELFYAML::dropUniqueSuffix(Name);
1181 
1183  Section = std::make_unique<ELFYAML::StackSizesSection>();
1184  else
1185  Section = std::make_unique<ELFYAML::RawContentSection>();
1186  }
1187 
1188  if (auto S = dyn_cast<ELFYAML::RawContentSection>(Section.get()))
1189  sectionMapping(IO, *S);
1190  else
1191  sectionMapping(IO, *cast<ELFYAML::StackSizesSection>(Section.get()));
1192  }
1193 }
1194 
1196  IO &io, std::unique_ptr<ELFYAML::Section> &Section) {
1197  if (const auto *RawSection =
1198  dyn_cast<ELFYAML::RawContentSection>(Section.get())) {
1199  if (RawSection->Size && RawSection->Content &&
1200  (uint64_t)(*RawSection->Size) < RawSection->Content->binary_size())
1201  return "Section size must be greater than or equal to the content size";
1202  return {};
1203  }
1204 
1205  if (const auto *SS = dyn_cast<ELFYAML::StackSizesSection>(Section.get())) {
1206  if (!SS->Entries && !SS->Content && !SS->Size)
1207  return ".stack_sizes: one of Content, Entries and Size must be specified";
1208 
1209  if (SS->Size && SS->Content &&
1210  (uint64_t)(*SS->Size) < SS->Content->binary_size())
1211  return ".stack_sizes: Size must be greater than or equal to the content "
1212  "size";
1213 
1214  // We accept Content, Size or both together when there are no Entries.
1215  if (!SS->Entries)
1216  return {};
1217 
1218  if (SS->Size)
1219  return ".stack_sizes: Size and Entries cannot be used together";
1220  if (SS->Content)
1221  return ".stack_sizes: Content and Entries cannot be used together";
1222  return {};
1223  }
1224 
1225  if (const auto *HS = dyn_cast<ELFYAML::HashSection>(Section.get())) {
1226  if (!HS->Content && !HS->Bucket && !HS->Chain && !HS->Size)
1227  return "one of \"Content\", \"Size\", \"Bucket\" or \"Chain\" must be "
1228  "specified";
1229 
1230  if (HS->Content || HS->Size) {
1231  if (HS->Size && HS->Content &&
1232  (uint64_t)*HS->Size < HS->Content->binary_size())
1233  return "\"Size\" must be greater than or equal to the content "
1234  "size";
1235 
1236  if (HS->Bucket)
1237  return "\"Bucket\" cannot be used with \"Content\" or \"Size\"";
1238  if (HS->Chain)
1239  return "\"Chain\" cannot be used with \"Content\" or \"Size\"";
1240  return {};
1241  }
1242 
1243  if ((HS->Bucket && !HS->Chain) || (!HS->Bucket && HS->Chain))
1244  return "\"Bucket\" and \"Chain\" must be used together";
1245  return {};
1246  }
1247 
1248  if (const auto *Sec = dyn_cast<ELFYAML::AddrsigSection>(Section.get())) {
1249  if (!Sec->Symbols && !Sec->Content && !Sec->Size)
1250  return "one of \"Content\", \"Size\" or \"Symbols\" must be specified";
1251 
1252  if (Sec->Content || Sec->Size) {
1253  if (Sec->Size && Sec->Content &&
1254  (uint64_t)*Sec->Size < Sec->Content->binary_size())
1255  return "\"Size\" must be greater than or equal to the content "
1256  "size";
1257 
1258  if (Sec->Symbols)
1259  return "\"Symbols\" cannot be used with \"Content\" or \"Size\"";
1260  return {};
1261  }
1262 
1263  if (!Sec->Symbols)
1264  return {};
1265 
1266  for (const ELFYAML::AddrsigSymbol &AS : *Sec->Symbols)
1267  if (AS.Index && AS.Name)
1268  return "\"Index\" and \"Name\" cannot be used together when defining a "
1269  "symbol";
1270  return {};
1271  }
1272 
1273  return {};
1274 }
1275 
1276 namespace {
1277 
1278 struct NormalizedMips64RelType {
1279  NormalizedMips64RelType(IO &)
1280  : Type(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
1281  Type2(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
1282  Type3(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
1283  SpecSym(ELFYAML::ELF_REL(ELF::RSS_UNDEF)) {}
1284  NormalizedMips64RelType(IO &, ELFYAML::ELF_REL Original)
1285  : Type(Original & 0xFF), Type2(Original >> 8 & 0xFF),
1286  Type3(Original >> 16 & 0xFF), SpecSym(Original >> 24 & 0xFF) {}
1287 
1288  ELFYAML::ELF_REL denormalize(IO &) {
1289  ELFYAML::ELF_REL Res = Type | Type2 << 8 | Type3 << 16 | SpecSym << 24;
1290  return Res;
1291  }
1292 
1293  ELFYAML::ELF_REL Type;
1294  ELFYAML::ELF_REL Type2;
1295  ELFYAML::ELF_REL Type3;
1296  ELFYAML::ELF_RSS SpecSym;
1297 };
1298 
1299 } // end anonymous namespace
1300 
1302  IO &IO, ELFYAML::StackSizeEntry &E) {
1303  assert(IO.getContext() && "The IO context is not initialized");
1304  IO.mapOptional("Address", E.Address, Hex64(0));
1305  IO.mapRequired("Size", E.Size);
1306 }
1307 
1309  ELFYAML::DynamicEntry &Rel) {
1310  assert(IO.getContext() && "The IO context is not initialized");
1311 
1312  IO.mapRequired("Tag", Rel.Tag);
1313  IO.mapRequired("Value", Rel.Val);
1314 }
1315 
1318  assert(IO.getContext() && "The IO context is not initialized");
1319 
1320  IO.mapRequired("Version", E.Version);
1321  IO.mapRequired("Flags", E.Flags);
1322  IO.mapRequired("VersionNdx", E.VersionNdx);
1323  IO.mapRequired("Hash", E.Hash);
1324  IO.mapRequired("Names", E.VerNames);
1325 }
1326 
1329  assert(IO.getContext() && "The IO context is not initialized");
1330 
1331  IO.mapRequired("Version", E.Version);
1332  IO.mapRequired("File", E.File);
1333  IO.mapRequired("Entries", E.AuxV);
1334 }
1335 
1338  assert(IO.getContext() && "The IO context is not initialized");
1339 
1340  IO.mapRequired("Name", E.Name);
1341  IO.mapRequired("Hash", E.Hash);
1342  IO.mapRequired("Flags", E.Flags);
1343  IO.mapRequired("Other", E.Other);
1344 }
1345 
1347  ELFYAML::Relocation &Rel) {
1348  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
1349  assert(Object && "The IO context is not initialized");
1350 
1351  IO.mapRequired("Offset", Rel.Offset);
1352  IO.mapOptional("Symbol", Rel.Symbol);
1353 
1354  if (Object->Header.Machine == ELFYAML::ELF_EM(ELF::EM_MIPS) &&
1355  Object->Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64)) {
1356  MappingNormalization<NormalizedMips64RelType, ELFYAML::ELF_REL> Key(
1357  IO, Rel.Type);
1358  IO.mapRequired("Type", Key->Type);
1359  IO.mapOptional("Type2", Key->Type2, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
1360  IO.mapOptional("Type3", Key->Type3, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
1361  IO.mapOptional("SpecSym", Key->SpecSym, ELFYAML::ELF_RSS(ELF::RSS_UNDEF));
1362  } else
1363  IO.mapRequired("Type", Rel.Type);
1364 
1365  IO.mapOptional("Addend", Rel.Addend, (int64_t)0);
1366 }
1367 
1369  assert(!IO.getContext() && "The IO context is initialized already");
1370  IO.setContext(&Object);
1371  IO.mapTag("!ELF", true);
1372  IO.mapRequired("FileHeader", Object.Header);
1373  IO.mapOptional("ProgramHeaders", Object.ProgramHeaders);
1374  IO.mapOptional("Sections", Object.Sections);
1375  IO.mapOptional("Symbols", Object.Symbols);
1376  IO.mapOptional("DynamicSymbols", Object.DynamicSymbols);
1377  IO.setContext(nullptr);
1378 }
1379 
1381  assert(IO.getContext() && "The IO context is not initialized");
1382  IO.mapOptional("Name", Sym.Name);
1383  IO.mapOptional("Index", Sym.Index);
1384 }
1385 
1386 LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_AFL_REG)
1387 LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_ABI_FP)
1388 LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_EXT)
1389 LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_ASE)
1390 LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_FLAGS1)
1391 
1392 } // end namespace yaml
1393 
1394 } // end namespace llvm
const NoneType None
Definition: None.h:23
This file declares classes for handling the YAML representation of ELF.
static void bitset(IO &IO, ELFYAML::ELF_SHF &Value)
Definition: ELFYAML.cpp:511
Optional< ELF_SHF > Flags
Definition: ELFYAML.h:146
Optional< llvm::yaml::Hex64 > Size
Definition: ELFYAML.h:271
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool to_integer(StringRef S, N &Num, unsigned Base=0)
Convert the string S to an integer of the specified type using the radix Base.
Definition: StringExtras.h:193
Optional< yaml::BinaryRef > Content
Definition: ELFYAML.h:177
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static void enumeration(IO &IO, ELFYAML::ELF_ET &Value)
Definition: ELFYAML.cpp:31
Optional< llvm::yaml::Hex64 > Align
Definition: ELFYAML.h:94
static void enumeration(IO &IO, ELFYAML::ELF_STT &Value)
Definition: ELFYAML.cpp:588
Optional< ELF_SHN > Index
Definition: ELFYAML.h:106
static void enumeration(IO &IO, ELFYAML::ELF_SHN &Value)
Definition: ELFYAML.cpp:554
Optional< llvm::yaml::Hex64 > Size
Definition: ELFYAML.h:178
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:953
llvm::yaml::Hex64 PAddr
Definition: ELFYAML.h:93
static void bitset(IO &IO, ELFYAML::ELF_PF &Value)
Definition: ELFYAML.cpp:503
std::vector< SectionName > Sections
Definition: ELFYAML.h:98
This class implements a map that also provides access to all stored values in a deterministic order...
Definition: MapVector.h:37
llvm::yaml::Hex16 Version
Definition: ELFYAML.h:352
Optional< llvm::yaml::Hex64 > Size
Definition: ELFYAML.h:205
ELFYAML::ELF_REL Type3
Definition: ELFYAML.cpp:1295
llvm::yaml::Hex64 Info
Definition: ELFYAML.h:300
llvm::yaml::Hex64 Address
Definition: ELFYAML.h:147
static void enumeration(IO &IO, ELFYAML::ELF_RSS &Value)
Definition: ELFYAML.cpp:604
FileHeader Header
Definition: ELFYAML.h:372
static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value)
Definition: ELFYAML.cpp:435
llvm::yaml::Hex64 Entry
Definition: ELFYAML.h:77
Optional< llvm::yaml::Hex64 > Size
Definition: ELFYAML.h:227
static void bitset(IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value)
Definition: ELFYAML.cpp:813
llvm::yaml::Hex64 AddressAlign
Definition: ELFYAML.h:149
Optional< llvm::yaml::Hex32 > Index
Definition: ELFYAML.h:266
llvm::yaml::Hex64 Size
Definition: ELFYAML.h:216
std::vector< DynamicEntry > Entries
Definition: ELFYAML.h:193
Optional< std::vector< StackSizeEntry > > Entries
Definition: ELFYAML.h:179
StringRef Section
Definition: ELFYAML.h:105
static void groupSectionMapping(IO &IO, ELFYAML::Group &Group)
Definition: ELFYAML.cpp:1063
static void enumeration(IO &IO, ELFYAML::ELF_EM &Value)
Definition: ELFYAML.cpp:61
llvm::yaml::Hex64 Size
Definition: ELFYAML.h:109
Optional< std::vector< uint32_t > > Chain
Definition: ELFYAML.h:229
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:140
llvm::yaml::Hex8 ABIVersion
Definition: ELFYAML.h:73
llvm::yaml::Hex64 Info
Definition: ELFYAML.h:251
Key
PAL metadata keys.
static void enumeration(IO &IO, ELFYAML::ELF_ELFCLASS &Value)
Definition: ELFYAML.cpp:227
Optional< llvm::yaml::Hex64 > EntSize
Definition: ELFYAML.h:150
ELFYAML::ELF_RSS SpecSym
Definition: ELFYAML.cpp:1296
static StringRef input(StringRef Scalar, void *, StOtherPiece &Val)
Definition: ELFYAML.cpp:856
static void output(const StOtherPiece &Val, void *, raw_ostream &Out)
Definition: ELFYAML.cpp:853
iterator find(const KeyT &Key)
Definition: MapVector.h:147
static void enumeration(IO &IO, ELFYAML::MIPS_ISA &Value)
Definition: ELFYAML.cpp:783
Optional< uint8_t > Other
Definition: ELFYAML.h:110
Optional< llvm::yaml::Hex64 > ShSize
Definition: ELFYAML.h:173
std::vector< ProgramHeader > ProgramHeaders
Definition: ELFYAML.h:373
Optional< std::vector< Symbol > > Symbols
Definition: ELFYAML.h:379
std::vector< VernauxEntry > AuxV
Definition: ELFYAML.h:246
static void commonSectionMapping(IO &IO, ELFYAML::Section &Section)
Definition: ELFYAML.cpp:988
#define P(N)
static void enumeration(IO &IO, ELFYAML::ELF_PT &Value)
Definition: ELFYAML.cpp:43
Optional< llvm::yaml::Hex16 > SHStrNdx
Definition: ELFYAML.h:82
std::string UnknownFlagsHolder
Definition: ELFYAML.cpp:954
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
static void enumeration(IO &IO, ELFYAML::ELF_DYNTAG &Value)
Definition: ELFYAML.cpp:665
llvm::yaml::Hex32 Flags2
Definition: ELFYAML.h:362
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define BCase(X)
static void enumeration(IO &IO, ELFYAML::ELF_REL &Value)
Definition: ELFYAML.cpp:614
std::vector< uint32_t > Entries
Definition: ELFYAML.h:341
Optional< llvm::yaml::Hex64 > SHOff
Definition: ELFYAML.h:80
std::vector< VerneedEntry > VerneedV
Definition: ELFYAML.h:250
std::vector< StringRef > VerNames
Definition: ELFYAML.h:295
StringRef Signature
Definition: ELFYAML.h:313
static QuotingType mustQuote(StringRef)
Definition: ELFYAML.cpp:860
static void sectionMapping(IO &IO, ELFYAML::DynamicSection &Section)
Definition: ELFYAML.cpp:1007
std::vector< std::unique_ptr< Section > > Sections
Definition: ELFYAML.h:374
Optional< yaml::BinaryRef > Content
Definition: ELFYAML.h:204
Optional< yaml::BinaryRef > Content
Definition: ELFYAML.h:194
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
llvm::yaml::Hex8 ISARevision
Definition: ELFYAML.h:354
Optional< llvm::yaml::Hex64 > MemSize
Definition: ELFYAML.h:96
StringRef dropUniqueSuffix(StringRef S)
Definition: ELFEmitter.cpp:361
static void bitset(IO &IO, ELFYAML::ELF_EF &Value)
Definition: ELFYAML.cpp:278
ELF_ELFCLASS Class
Definition: ELFYAML.h:70
std::vector< SectionOrType > Members
Definition: ELFYAML.h:312
Optional< llvm::yaml::Hex64 > ShOffset
Definition: ELFYAML.h:169
Optional< StringRef > Name
Definition: ELFYAML.h:265
static bool nameMatches(StringRef Name)
Definition: ELFYAML.h:187
llvm::yaml::Hex64 Offset
Definition: ELFYAML.h:323
static uint32_t getFlags(const Symbol *Sym)
Definition: TapiFile.cpp:28
std::vector< Symbol > DynamicSymbols
Definition: ELFYAML.h:380
static void enumeration(IO &IO, ELFYAML::ELF_ELFOSABI &Value)
Definition: ELFYAML.cpp:248
Optional< llvm::yaml::Hex16 > SHNum
Definition: ELFYAML.h:81
static void bitset(IO &IO, ELFYAML::MIPS_AFL_ASE &Value)
Definition: ELFYAML.cpp:794
Optional< llvm::yaml::Hex64 > Info
Definition: ELFYAML.h:206
Optional< llvm::yaml::Hex64 > ShName
Definition: ELFYAML.h:165
static void enumeration(IO &IO, ELFYAML::MIPS_AFL_EXT &Value)
Definition: ELFYAML.cpp:757
#define ECase(X)
bool hasValue() const
Definition: Optional.h:259
ELFYAML::ELF_REL Type2
Definition: ELFYAML.cpp:1294
llvm::yaml::Hex64 Address
Definition: ELFYAML.h:123
static void enumeration(IO &IO, ELFYAML::MIPS_ABI_FP &Value)
Definition: ELFYAML.cpp:743
MIPS_AFL_EXT ISAExtension
Definition: ELFYAML.h:359
Optional< std::vector< uint32_t > > Bucket
Definition: ELFYAML.h:228
llvm::yaml::Hex64 Value
Definition: ELFYAML.h:108
static void enumeration(IO &IO, ELFYAML::ELF_STB &Value)
Definition: ELFYAML.cpp:577
static void enumeration(IO &IO, ELFYAML::ELF_ELFDATA &Value)
Definition: ELFYAML.cpp:237
Optional< std::vector< AddrsigSymbol > > Symbols
Definition: ELFYAML.h:272
Optional< yaml::BinaryRef > Content
Definition: ELFYAML.h:270
Optional< llvm::yaml::Hex64 > FileSize
Definition: ELFYAML.h:95
std::vector< VerdefEntry > Entries
Definition: ELFYAML.h:299
const std::string to_string(const T &Value)
Definition: ScopedPrinter.h:61
Optional< llvm::yaml::Hex16 > SHEntSize
Definition: ELFYAML.h:79
Optional< uint32_t > NameIndex
Definition: ELFYAML.h:103
MIPS_AFL_FLAGS1 Flags1
Definition: ELFYAML.h:361
IO & YamlIO
Definition: ELFYAML.cpp:952
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:136
iterator end()
Definition: MapVector.h:71
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Definition: Value.h:74
llvm::yaml::Hex64 Val
Definition: ELFYAML.h:119
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Optional< yaml::BinaryRef > Content
Definition: ELFYAML.h:226
std::vector< uint16_t > Entries
Definition: ELFYAML.h:281
static void enumeration(IO &IO, ELFYAML::MIPS_AFL_REG &Value)
Definition: ELFYAML.cpp:733
ELF_ELFOSABI OSABI
Definition: ELFYAML.h:72
llvm::yaml::Hex64 VAddr
Definition: ELFYAML.h:92
#define BCaseMask(X, M)
Optional< StringRef > Symbol
Definition: ELFYAML.h:326
llvm::yaml::Hex64 Size
Definition: ELFYAML.h:124
std::vector< Relocation > Relocations
Definition: ELFYAML.h:330
void validate(const Triple &TT, const FeatureBitset &FeatureBits)
Optional< llvm::yaml::Hex64 > Offset
Definition: ELFYAML.h:97