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 }
225 
227  IO &IO, ELFYAML::ELF_ELFCLASS &Value) {
228 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
229  // Since the semantics of ELFCLASSNONE is "invalid", just don't accept it
230  // here.
231  ECase(ELFCLASS32);
232  ECase(ELFCLASS64);
233 #undef ECase
234 }
235 
237  IO &IO, ELFYAML::ELF_ELFDATA &Value) {
238 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
239  // ELFDATANONE is an invalid data encoding, but we accept it because
240  // we want to be able to produce invalid binaries for the tests.
244 #undef ECase
245 }
246 
248  IO &IO, ELFYAML::ELF_ELFOSABI &Value) {
249 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
274 #undef ECase
275 }
276 
278  ELFYAML::ELF_EF &Value) {
279  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
280  assert(Object && "The IO context is not initialized");
281 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
282 #define BCaseMask(X, M) IO.maskedBitSetCase(Value, #X, ELF::X, ELF::M)
283  switch (Object->Header.Machine) {
284  case ELF::EM_ARM:
293  break;
294  case ELF::EM_MIPS:
338  break;
339  case ELF::EM_HEXAGON:
356  break;
357  case ELF::EM_AVR:
375  break;
376  case ELF::EM_RISCV:
383  break;
384  case ELF::EM_AMDGPU:
424  break;
425  case ELF::EM_X86_64:
426  break;
427  default:
428  llvm_unreachable("Unsupported architecture");
429  }
430 #undef BCase
431 #undef BCaseMask
432 }
433 
435  IO &IO, ELFYAML::ELF_SHT &Value) {
436  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
437  assert(Object && "The IO context is not initialized");
438 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
439  ECase(SHT_NULL);
441  ECase(SHT_SYMTAB);
442  // FIXME: Issue a diagnostic with this information.
443  ECase(SHT_STRTAB);
444  ECase(SHT_RELA);
445  ECase(SHT_HASH);
447  ECase(SHT_NOTE);
448  ECase(SHT_NOBITS);
449  ECase(SHT_REL);
450  ECase(SHT_SHLIB);
451  ECase(SHT_DYNSYM);
455  ECase(SHT_GROUP);
457  ECase(SHT_RELR);
474  switch (Object->Header.Machine) {
475  case ELF::EM_ARM:
481  break;
482  case ELF::EM_HEXAGON:
484  break;
485  case ELF::EM_X86_64:
487  break;
488  case ELF::EM_MIPS:
493  break;
494  default:
495  // Nothing to do.
496  break;
497  }
498 #undef ECase
499  IO.enumFallback<Hex32>(Value);
500 }
501 
503  ELFYAML::ELF_PF &Value) {
504 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
505  BCase(PF_X);
506  BCase(PF_W);
507  BCase(PF_R);
508 }
509 
511  ELFYAML::ELF_SHF &Value) {
512  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
513 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
514  BCase(SHF_WRITE);
515  BCase(SHF_ALLOC);
518  BCase(SHF_MERGE);
523  BCase(SHF_GROUP);
524  BCase(SHF_TLS);
526  switch (Object->Header.Machine) {
527  case ELF::EM_ARM:
529  break;
530  case ELF::EM_HEXAGON:
532  break;
533  case ELF::EM_MIPS:
542  break;
543  case ELF::EM_X86_64:
545  break;
546  default:
547  // Nothing to do.
548  break;
549  }
550 #undef BCase
551 }
552 
554  IO &IO, ELFYAML::ELF_SHN &Value) {
555 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
556  ECase(SHN_UNDEF);
558  ECase(SHN_LOPROC);
559  ECase(SHN_HIPROC);
560  ECase(SHN_LOOS);
561  ECase(SHN_HIOS);
562  ECase(SHN_ABS);
563  ECase(SHN_COMMON);
564  ECase(SHN_XINDEX);
572 #undef ECase
573  IO.enumFallback<Hex16>(Value);
574 }
575 
577  IO &IO, ELFYAML::ELF_STB &Value) {
578 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
579  ECase(STB_LOCAL);
580  ECase(STB_GLOBAL);
581  ECase(STB_WEAK);
583 #undef ECase
584  IO.enumFallback<Hex8>(Value);
585 }
586 
588  IO &IO, ELFYAML::ELF_STT &Value) {
589 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
590  ECase(STT_NOTYPE);
591  ECase(STT_OBJECT);
592  ECase(STT_FUNC);
594  ECase(STT_FILE);
595  ECase(STT_COMMON);
596  ECase(STT_TLS);
598 #undef ECase
599  IO.enumFallback<Hex8>(Value);
600 }
601 
602 
604  IO &IO, ELFYAML::ELF_RSS &Value) {
605 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
606  ECase(RSS_UNDEF);
607  ECase(RSS_GP);
608  ECase(RSS_GP0);
609  ECase(RSS_LOC);
610 #undef ECase
611 }
612 
614  IO &IO, ELFYAML::ELF_REL &Value) {
615  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
616  assert(Object && "The IO context is not initialized");
617 #define ELF_RELOC(X, Y) IO.enumCase(Value, #X, ELF::X);
618  switch (Object->Header.Machine) {
619  case ELF::EM_X86_64:
620 #include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
621  break;
622  case ELF::EM_MIPS:
623 #include "llvm/BinaryFormat/ELFRelocs/Mips.def"
624  break;
625  case ELF::EM_HEXAGON:
626 #include "llvm/BinaryFormat/ELFRelocs/Hexagon.def"
627  break;
628  case ELF::EM_386:
629  case ELF::EM_IAMCU:
630 #include "llvm/BinaryFormat/ELFRelocs/i386.def"
631  break;
632  case ELF::EM_AARCH64:
633 #include "llvm/BinaryFormat/ELFRelocs/AArch64.def"
634  break;
635  case ELF::EM_ARM:
636 #include "llvm/BinaryFormat/ELFRelocs/ARM.def"
637  break;
638  case ELF::EM_ARC:
639 #include "llvm/BinaryFormat/ELFRelocs/ARC.def"
640  break;
641  case ELF::EM_RISCV:
642 #include "llvm/BinaryFormat/ELFRelocs/RISCV.def"
643  break;
644  case ELF::EM_LANAI:
645 #include "llvm/BinaryFormat/ELFRelocs/Lanai.def"
646  break;
647  case ELF::EM_AMDGPU:
648 #include "llvm/BinaryFormat/ELFRelocs/AMDGPU.def"
649  break;
650  case ELF::EM_BPF:
651 #include "llvm/BinaryFormat/ELFRelocs/BPF.def"
652  break;
653  default:
654  llvm_unreachable("Unsupported architecture");
655  }
656 #undef ELF_RELOC
657  IO.enumFallback<Hex32>(Value);
658 }
659 
661  IO &IO, ELFYAML::ELF_DYNTAG &Value) {
662  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
663  assert(Object && "The IO context is not initialized");
664 
665 // Disable architecture specific tags by default. We might enable them below.
666 #define AARCH64_DYNAMIC_TAG(name, value)
667 #define MIPS_DYNAMIC_TAG(name, value)
668 #define HEXAGON_DYNAMIC_TAG(name, value)
669 #define PPC_DYNAMIC_TAG(name, value)
670 #define PPC64_DYNAMIC_TAG(name, value)
671 // Ignore marker tags such as DT_HIOS (maps to DT_VERNEEDNUM), etc.
672 #define DYNAMIC_TAG_MARKER(name, value)
673 
674 #define STRINGIFY(X) (#X)
675 #define DYNAMIC_TAG(X, Y) IO.enumCase(Value, STRINGIFY(DT_##X), ELF::DT_##X);
676  switch (Object->Header.Machine) {
677  case ELF::EM_AARCH64:
678 #undef AARCH64_DYNAMIC_TAG
679 #define AARCH64_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
680 #include "llvm/BinaryFormat/DynamicTags.def"
681 #undef AARCH64_DYNAMIC_TAG
682 #define AARCH64_DYNAMIC_TAG(name, value)
683  break;
684  case ELF::EM_MIPS:
685 #undef MIPS_DYNAMIC_TAG
686 #define MIPS_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
687 #include "llvm/BinaryFormat/DynamicTags.def"
688 #undef MIPS_DYNAMIC_TAG
689 #define MIPS_DYNAMIC_TAG(name, value)
690  break;
691  case ELF::EM_HEXAGON:
692 #undef HEXAGON_DYNAMIC_TAG
693 #define HEXAGON_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
694 #include "llvm/BinaryFormat/DynamicTags.def"
695 #undef HEXAGON_DYNAMIC_TAG
696 #define HEXAGON_DYNAMIC_TAG(name, value)
697  break;
698  case ELF::EM_PPC:
699 #undef PPC_DYNAMIC_TAG
700 #define PPC_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
701 #include "llvm/BinaryFormat/DynamicTags.def"
702 #undef PPC_DYNAMIC_TAG
703 #define PPC_DYNAMIC_TAG(name, value)
704  break;
705  case ELF::EM_PPC64:
706 #undef PPC64_DYNAMIC_TAG
707 #define PPC64_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
708 #include "llvm/BinaryFormat/DynamicTags.def"
709 #undef PPC64_DYNAMIC_TAG
710 #define PPC64_DYNAMIC_TAG(name, value)
711  break;
712  default:
713 #include "llvm/BinaryFormat/DynamicTags.def"
714  break;
715  }
716 #undef AARCH64_DYNAMIC_TAG
717 #undef MIPS_DYNAMIC_TAG
718 #undef HEXAGON_DYNAMIC_TAG
719 #undef PPC_DYNAMIC_TAG
720 #undef PPC64_DYNAMIC_TAG
721 #undef DYNAMIC_TAG_MARKER
722 #undef STRINGIFY
723 #undef DYNAMIC_TAG
724 
725  IO.enumFallback<Hex64>(Value);
726 }
727 
729  IO &IO, ELFYAML::MIPS_AFL_REG &Value) {
730 #define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X)
731  ECase(REG_NONE);
732  ECase(REG_32);
733  ECase(REG_64);
734  ECase(REG_128);
735 #undef ECase
736 }
737 
739  IO &IO, ELFYAML::MIPS_ABI_FP &Value) {
740 #define ECase(X) IO.enumCase(Value, #X, Mips::Val_GNU_MIPS_ABI_##X)
741  ECase(FP_ANY);
742  ECase(FP_DOUBLE);
743  ECase(FP_SINGLE);
744  ECase(FP_SOFT);
745  ECase(FP_OLD_64);
746  ECase(FP_XX);
747  ECase(FP_64);
748  ECase(FP_64A);
749 #undef ECase
750 }
751 
753  IO &IO, ELFYAML::MIPS_AFL_EXT &Value) {
754 #define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X)
755  ECase(EXT_NONE);
756  ECase(EXT_XLR);
757  ECase(EXT_OCTEON2);
758  ECase(EXT_OCTEONP);
759  ECase(EXT_LOONGSON_3A);
760  ECase(EXT_OCTEON);
761  ECase(EXT_5900);
762  ECase(EXT_4650);
763  ECase(EXT_4010);
764  ECase(EXT_4100);
765  ECase(EXT_3900);
766  ECase(EXT_10000);
767  ECase(EXT_SB1);
768  ECase(EXT_4111);
769  ECase(EXT_4120);
770  ECase(EXT_5400);
771  ECase(EXT_5500);
772  ECase(EXT_LOONGSON_2E);
773  ECase(EXT_LOONGSON_2F);
774  ECase(EXT_OCTEON3);
775 #undef ECase
776 }
777 
779  IO &IO, ELFYAML::MIPS_ISA &Value) {
780  IO.enumCase(Value, "MIPS1", 1);
781  IO.enumCase(Value, "MIPS2", 2);
782  IO.enumCase(Value, "MIPS3", 3);
783  IO.enumCase(Value, "MIPS4", 4);
784  IO.enumCase(Value, "MIPS5", 5);
785  IO.enumCase(Value, "MIPS32", 32);
786  IO.enumCase(Value, "MIPS64", 64);
787 }
788 
790  IO &IO, ELFYAML::MIPS_AFL_ASE &Value) {
791 #define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_ASE_##X)
792  BCase(DSP);
793  BCase(DSPR2);
794  BCase(EVA);
795  BCase(MCU);
796  BCase(MDMX);
797  BCase(MIPS3D);
798  BCase(MT);
799  BCase(SMARTMIPS);
800  BCase(VIRT);
801  BCase(MSA);
802  BCase(MIPS16);
803  BCase(MICROMIPS);
804  BCase(XPA);
805 #undef BCase
806 }
807 
809  IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value) {
810 #define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_FLAGS1_##X)
811  BCase(ODDSPREG);
812 #undef BCase
813 }
814 
816  ELFYAML::FileHeader &FileHdr) {
817  IO.mapRequired("Class", FileHdr.Class);
818  IO.mapRequired("Data", FileHdr.Data);
819  IO.mapOptional("OSABI", FileHdr.OSABI, ELFYAML::ELF_ELFOSABI(0));
820  IO.mapOptional("ABIVersion", FileHdr.ABIVersion, Hex8(0));
821  IO.mapRequired("Type", FileHdr.Type);
822  IO.mapRequired("Machine", FileHdr.Machine);
823  IO.mapOptional("Flags", FileHdr.Flags, ELFYAML::ELF_EF(0));
824  IO.mapOptional("Entry", FileHdr.Entry, Hex64(0));
825 
826  IO.mapOptional("SHEntSize", FileHdr.SHEntSize);
827  IO.mapOptional("SHOff", FileHdr.SHOff);
828  IO.mapOptional("SHNum", FileHdr.SHNum);
829  IO.mapOptional("SHStrNdx", FileHdr.SHStrNdx);
830 }
831 
833  IO &IO, ELFYAML::ProgramHeader &Phdr) {
834  IO.mapRequired("Type", Phdr.Type);
835  IO.mapOptional("Flags", Phdr.Flags, ELFYAML::ELF_PF(0));
836  IO.mapOptional("Sections", Phdr.Sections);
837  IO.mapOptional("VAddr", Phdr.VAddr, Hex64(0));
838  IO.mapOptional("PAddr", Phdr.PAddr, Hex64(0));
839  IO.mapOptional("Align", Phdr.Align);
840  IO.mapOptional("FileSize", Phdr.FileSize);
841  IO.mapOptional("MemSize", Phdr.MemSize);
842  IO.mapOptional("Offset", Phdr.Offset);
843 }
844 
845 LLVM_YAML_STRONG_TYPEDEF(StringRef, StOtherPiece)
846 
847 template <> struct ScalarTraits<StOtherPiece> {
848  static void output(const StOtherPiece &Val, void *, raw_ostream &Out) {
849  Out << Val;
850  }
851  static StringRef input(StringRef Scalar, void *, StOtherPiece &Val) {
852  Val = Scalar;
853  return {};
854  }
855  static QuotingType mustQuote(StringRef) { return QuotingType::None; }
856 };
857 template <> struct SequenceElementTraits<StOtherPiece> {
858  static const bool flow = true;
859 };
860 
861 namespace {
862 
863 struct NormalizedOther {
864  NormalizedOther(IO &IO) : YamlIO(IO) {}
865  NormalizedOther(IO &IO, Optional<uint8_t> Original) : YamlIO(IO) {
866  assert(Original && "This constructor is only used for outputting YAML and "
867  "assumes a non-empty Original");
868  std::vector<StOtherPiece> Ret;
869  const auto *Object = static_cast<ELFYAML::Object *>(YamlIO.getContext());
870  for (std::pair<StringRef, uint8_t> &P :
871  getFlags(Object->Header.Machine).takeVector()) {
872  uint8_t FlagValue = P.second;
873  if ((*Original & FlagValue) != FlagValue)
874  continue;
875  *Original &= ~FlagValue;
876  Ret.push_back({P.first});
877  }
878 
879  if (*Original != 0) {
880  UnknownFlagsHolder = std::to_string(*Original);
881  Ret.push_back({UnknownFlagsHolder});
882  }
883 
884  if (!Ret.empty())
885  Other = std::move(Ret);
886  }
887 
888  uint8_t toValue(StringRef Name) {
889  const auto *Object = static_cast<ELFYAML::Object *>(YamlIO.getContext());
890  MapVector<StringRef, uint8_t> Flags = getFlags(Object->Header.Machine);
891 
892  auto It = Flags.find(Name);
893  if (It != Flags.end())
894  return It->second;
895 
896  uint8_t Val;
897  if (to_integer(Name, Val))
898  return Val;
899 
900  YamlIO.setError("an unknown value is used for symbol's 'Other' field: " +
901  Name);
902  return 0;
903  }
904 
905  Optional<uint8_t> denormalize(IO &) {
906  if (!Other)
907  return None;
908  uint8_t Ret = 0;
909  for (StOtherPiece &Val : *Other)
910  Ret |= toValue(Val);
911  return Ret;
912  }
913 
914  // st_other field is used to encode symbol visibility and platform-dependent
915  // flags and values. This method returns a name to value map that is used for
916  // parsing and encoding this field.
917  MapVector<StringRef, uint8_t> getFlags(unsigned EMachine) {
919  // STV_* values are just enumeration values. We add them in a reversed order
920  // because when we convert the st_other to named constants when printing
921  // YAML we want to use a maximum number of bits on each step:
922  // when we have st_other == 3, we want to print it as STV_PROTECTED (3), but
923  // not as STV_HIDDEN (2) + STV_INTERNAL (1).
924  Map["STV_PROTECTED"] = ELF::STV_PROTECTED;
925  Map["STV_HIDDEN"] = ELF::STV_HIDDEN;
926  Map["STV_INTERNAL"] = ELF::STV_INTERNAL;
927  // STV_DEFAULT is used to represent the default visibility and has a value
928  // 0. We want to be able to read it from YAML documents, but there is no
929  // reason to print it.
930  if (!YamlIO.outputting())
931  Map["STV_DEFAULT"] = ELF::STV_DEFAULT;
932 
933  // MIPS is not consistent. All of the STO_MIPS_* values are bit flags,
934  // except STO_MIPS_MIPS16 which overlaps them. It should be checked and
935  // consumed first when we print the output, because we do not want to print
936  // any other flags that have the same bits instead.
937  if (EMachine == ELF::EM_MIPS) {
938  Map["STO_MIPS_MIPS16"] = ELF::STO_MIPS_MIPS16;
939  Map["STO_MIPS_MICROMIPS"] = ELF::STO_MIPS_MICROMIPS;
940  Map["STO_MIPS_PIC"] = ELF::STO_MIPS_PIC;
941  Map["STO_MIPS_PLT"] = ELF::STO_MIPS_PLT;
942  Map["STO_MIPS_OPTIONAL"] = ELF::STO_MIPS_OPTIONAL;
943  }
944  return Map;
945  }
946 
947  IO &YamlIO;
948  Optional<std::vector<StOtherPiece>> Other;
949  std::string UnknownFlagsHolder;
950 };
951 
952 } // end anonymous namespace
953 
955  IO.mapOptional("Name", Symbol.Name, StringRef());
956  IO.mapOptional("NameIndex", Symbol.NameIndex);
957  IO.mapOptional("Type", Symbol.Type, ELFYAML::ELF_STT(0));
958  IO.mapOptional("Section", Symbol.Section, StringRef());
959  IO.mapOptional("Index", Symbol.Index);
960  IO.mapOptional("Binding", Symbol.Binding, ELFYAML::ELF_STB(0));
961  IO.mapOptional("Value", Symbol.Value, Hex64(0));
962  IO.mapOptional("Size", Symbol.Size, Hex64(0));
963 
964  // Symbol's Other field is a bit special. It is usually a field that
965  // represents st_other and holds the symbol visibility. However, on some
966  // platforms, it can contain bit fields and regular values, or even sometimes a
967  // crazy mix of them (see comments for NormalizedOther). Because of this, we
968  // need special handling.
969  MappingNormalization<NormalizedOther, Optional<uint8_t>> Keys(IO,
970  Symbol.Other);
971  IO.mapOptional("Other", Keys->Other);
972 }
973 
976  if (Symbol.Index && Symbol.Section.data())
977  return "Index and Section cannot both be specified for Symbol";
978  if (Symbol.NameIndex && !Symbol.Name.empty())
979  return "Name and NameIndex cannot both be specified for Symbol";
980  return StringRef();
981 }
982 
984  IO.mapOptional("Name", Section.Name, StringRef());
985  IO.mapRequired("Type", Section.Type);
986  IO.mapOptional("Flags", Section.Flags);
987  IO.mapOptional("Address", Section.Address, Hex64(0));
988  IO.mapOptional("Link", Section.Link, StringRef());
989  IO.mapOptional("AddressAlign", Section.AddressAlign, Hex64(0));
990  IO.mapOptional("EntSize", Section.EntSize);
991 
992  // obj2yaml does not dump these fields. They are expected to be empty when we
993  // are producing YAML, because yaml2obj sets appropriate values for them
994  // automatically when they are not explicitly defined.
995  assert(!IO.outputting() ||
996  (!Section.ShOffset.hasValue() && !Section.ShSize.hasValue()));
997  IO.mapOptional("ShName", Section.ShName);
998  IO.mapOptional("ShOffset", Section.ShOffset);
999  IO.mapOptional("ShSize", Section.ShSize);
1000 }
1001 
1003  commonSectionMapping(IO, Section);
1004  IO.mapOptional("Entries", Section.Entries);
1005  IO.mapOptional("Content", Section.Content);
1006 }
1007 
1009  commonSectionMapping(IO, Section);
1010  IO.mapOptional("Content", Section.Content);
1011  IO.mapOptional("Size", Section.Size);
1012  IO.mapOptional("Info", Section.Info);
1013 }
1014 
1016  commonSectionMapping(IO, Section);
1017  IO.mapOptional("Size", Section.Size, Hex64(0));
1018 }
1019 
1021  commonSectionMapping(IO, Section);
1022  IO.mapRequired("Info", Section.Info);
1023  IO.mapRequired("Entries", Section.Entries);
1024 }
1025 
1027  commonSectionMapping(IO, Section);
1028  IO.mapRequired("Entries", Section.Entries);
1029 }
1030 
1032  commonSectionMapping(IO, Section);
1033  IO.mapRequired("Info", Section.Info);
1034  IO.mapRequired("Dependencies", Section.VerneedV);
1035 }
1036 
1038  commonSectionMapping(IO, Section);
1039  IO.mapOptional("Info", Section.RelocatableSec, StringRef());
1040  IO.mapOptional("Relocations", Section.Relocations);
1041 }
1042 
1043 static void groupSectionMapping(IO &IO, ELFYAML::Group &Group) {
1044  commonSectionMapping(IO, Group);
1045  IO.mapOptional("Info", Group.Signature, StringRef());
1046  IO.mapRequired("Members", Group.Members);
1047 }
1048 
1050  commonSectionMapping(IO, Section);
1051  IO.mapRequired("Entries", Section.Entries);
1052 }
1053 
1055  IO &IO, ELFYAML::SectionOrType &sectionOrType) {
1056  IO.mapRequired("SectionOrType", sectionOrType.sectionNameOrType);
1057 }
1058 
1060  IO &IO, ELFYAML::SectionName &sectionName) {
1061  IO.mapRequired("Section", sectionName.Section);
1062 }
1063 
1065  commonSectionMapping(IO, Section);
1066  IO.mapOptional("Version", Section.Version, Hex16(0));
1067  IO.mapRequired("ISA", Section.ISALevel);
1068  IO.mapOptional("ISARevision", Section.ISARevision, Hex8(0));
1069  IO.mapOptional("ISAExtension", Section.ISAExtension,
1070  ELFYAML::MIPS_AFL_EXT(Mips::AFL_EXT_NONE));
1071  IO.mapOptional("ASEs", Section.ASEs, ELFYAML::MIPS_AFL_ASE(0));
1072  IO.mapOptional("FpABI", Section.FpABI,
1073  ELFYAML::MIPS_ABI_FP(Mips::Val_GNU_MIPS_ABI_FP_ANY));
1074  IO.mapOptional("GPRSize", Section.GPRSize,
1075  ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
1076  IO.mapOptional("CPR1Size", Section.CPR1Size,
1077  ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
1078  IO.mapOptional("CPR2Size", Section.CPR2Size,
1079  ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
1080  IO.mapOptional("Flags1", Section.Flags1, ELFYAML::MIPS_AFL_FLAGS1(0));
1081  IO.mapOptional("Flags2", Section.Flags2, Hex32(0));
1082 }
1083 
1085  IO &IO, std::unique_ptr<ELFYAML::Section> &Section) {
1086  ELFYAML::ELF_SHT sectionType;
1087  if (IO.outputting())
1088  sectionType = Section->Type;
1089  else
1090  IO.mapRequired("Type", sectionType);
1091 
1092  switch (sectionType) {
1093  case ELF::SHT_DYNAMIC:
1094  if (!IO.outputting())
1095  Section.reset(new ELFYAML::DynamicSection());
1096  sectionMapping(IO, *cast<ELFYAML::DynamicSection>(Section.get()));
1097  break;
1098  case ELF::SHT_REL:
1099  case ELF::SHT_RELA:
1100  if (!IO.outputting())
1101  Section.reset(new ELFYAML::RelocationSection());
1102  sectionMapping(IO, *cast<ELFYAML::RelocationSection>(Section.get()));
1103  break;
1104  case ELF::SHT_GROUP:
1105  if (!IO.outputting())
1106  Section.reset(new ELFYAML::Group());
1107  groupSectionMapping(IO, *cast<ELFYAML::Group>(Section.get()));
1108  break;
1109  case ELF::SHT_NOBITS:
1110  if (!IO.outputting())
1111  Section.reset(new ELFYAML::NoBitsSection());
1112  sectionMapping(IO, *cast<ELFYAML::NoBitsSection>(Section.get()));
1113  break;
1115  if (!IO.outputting())
1116  Section.reset(new ELFYAML::MipsABIFlags());
1117  sectionMapping(IO, *cast<ELFYAML::MipsABIFlags>(Section.get()));
1118  break;
1119  case ELF::SHT_GNU_verdef:
1120  if (!IO.outputting())
1121  Section.reset(new ELFYAML::VerdefSection());
1122  sectionMapping(IO, *cast<ELFYAML::VerdefSection>(Section.get()));
1123  break;
1124  case ELF::SHT_GNU_versym:
1125  if (!IO.outputting())
1126  Section.reset(new ELFYAML::SymverSection());
1127  sectionMapping(IO, *cast<ELFYAML::SymverSection>(Section.get()));
1128  break;
1129  case ELF::SHT_GNU_verneed:
1130  if (!IO.outputting())
1131  Section.reset(new ELFYAML::VerneedSection());
1132  sectionMapping(IO, *cast<ELFYAML::VerneedSection>(Section.get()));
1133  break;
1134  case ELF::SHT_SYMTAB_SHNDX:
1135  if (!IO.outputting())
1136  Section.reset(new ELFYAML::SymtabShndxSection());
1137  sectionMapping(IO, *cast<ELFYAML::SymtabShndxSection>(Section.get()));
1138  break;
1139  default:
1140  if (!IO.outputting())
1141  Section.reset(new ELFYAML::RawContentSection());
1142  sectionMapping(IO, *cast<ELFYAML::RawContentSection>(Section.get()));
1143  }
1144 }
1145 
1147  IO &io, std::unique_ptr<ELFYAML::Section> &Section) {
1148  const auto *RawSection = dyn_cast<ELFYAML::RawContentSection>(Section.get());
1149  if (!RawSection)
1150  return {};
1151  if (RawSection->Size && RawSection->Content &&
1152  (uint64_t)(*RawSection->Size) < RawSection->Content->binary_size())
1153  return "Section size must be greater than or equal to the content size";
1154  return {};
1155 }
1156 
1157 namespace {
1158 
1159 struct NormalizedMips64RelType {
1160  NormalizedMips64RelType(IO &)
1161  : Type(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
1162  Type2(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
1163  Type3(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
1164  SpecSym(ELFYAML::ELF_REL(ELF::RSS_UNDEF)) {}
1165  NormalizedMips64RelType(IO &, ELFYAML::ELF_REL Original)
1166  : Type(Original & 0xFF), Type2(Original >> 8 & 0xFF),
1167  Type3(Original >> 16 & 0xFF), SpecSym(Original >> 24 & 0xFF) {}
1168 
1169  ELFYAML::ELF_REL denormalize(IO &) {
1170  ELFYAML::ELF_REL Res = Type | Type2 << 8 | Type3 << 16 | SpecSym << 24;
1171  return Res;
1172  }
1173 
1174  ELFYAML::ELF_REL Type;
1175  ELFYAML::ELF_REL Type2;
1176  ELFYAML::ELF_REL Type3;
1177  ELFYAML::ELF_RSS SpecSym;
1178 };
1179 
1180 } // end anonymous namespace
1181 
1183  ELFYAML::DynamicEntry &Rel) {
1184  assert(IO.getContext() && "The IO context is not initialized");
1185 
1186  IO.mapRequired("Tag", Rel.Tag);
1187  IO.mapRequired("Value", Rel.Val);
1188 }
1189 
1192  assert(IO.getContext() && "The IO context is not initialized");
1193 
1194  IO.mapRequired("Version", E.Version);
1195  IO.mapRequired("Flags", E.Flags);
1196  IO.mapRequired("VersionNdx", E.VersionNdx);
1197  IO.mapRequired("Hash", E.Hash);
1198  IO.mapRequired("Names", E.VerNames);
1199 }
1200 
1203  assert(IO.getContext() && "The IO context is not initialized");
1204 
1205  IO.mapRequired("Version", E.Version);
1206  IO.mapRequired("File", E.File);
1207  IO.mapRequired("Entries", E.AuxV);
1208 }
1209 
1212  assert(IO.getContext() && "The IO context is not initialized");
1213 
1214  IO.mapRequired("Name", E.Name);
1215  IO.mapRequired("Hash", E.Hash);
1216  IO.mapRequired("Flags", E.Flags);
1217  IO.mapRequired("Other", E.Other);
1218 }
1219 
1221  ELFYAML::Relocation &Rel) {
1222  const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
1223  assert(Object && "The IO context is not initialized");
1224 
1225  IO.mapRequired("Offset", Rel.Offset);
1226  IO.mapOptional("Symbol", Rel.Symbol);
1227 
1228  if (Object->Header.Machine == ELFYAML::ELF_EM(ELF::EM_MIPS) &&
1229  Object->Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64)) {
1230  MappingNormalization<NormalizedMips64RelType, ELFYAML::ELF_REL> Key(
1231  IO, Rel.Type);
1232  IO.mapRequired("Type", Key->Type);
1233  IO.mapOptional("Type2", Key->Type2, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
1234  IO.mapOptional("Type3", Key->Type3, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
1235  IO.mapOptional("SpecSym", Key->SpecSym, ELFYAML::ELF_RSS(ELF::RSS_UNDEF));
1236  } else
1237  IO.mapRequired("Type", Rel.Type);
1238 
1239  IO.mapOptional("Addend", Rel.Addend, (int64_t)0);
1240 }
1241 
1243  assert(!IO.getContext() && "The IO context is initialized already");
1244  IO.setContext(&Object);
1245  IO.mapTag("!ELF", true);
1246  IO.mapRequired("FileHeader", Object.Header);
1247  IO.mapOptional("ProgramHeaders", Object.ProgramHeaders);
1248  IO.mapOptional("Sections", Object.Sections);
1249  IO.mapOptional("Symbols", Object.Symbols);
1250  IO.mapOptional("DynamicSymbols", Object.DynamicSymbols);
1251  IO.setContext(nullptr);
1252 }
1253 
1254 LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_AFL_REG)
1255 LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_ABI_FP)
1256 LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_EXT)
1257 LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_ASE)
1258 LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_FLAGS1)
1259 
1260 } // end namespace yaml
1261 
1262 } // 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:510
Optional< ELF_SHF > Flags
Definition: ELFYAML.h:136
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
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:92
static void enumeration(IO &IO, ELFYAML::ELF_STT &Value)
Definition: ELFYAML.cpp:587
Optional< ELF_SHN > Index
Definition: ELFYAML.h:104
static void enumeration(IO &IO, ELFYAML::ELF_SHN &Value)
Definition: ELFYAML.cpp:553
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:948
llvm::yaml::Hex64 PAddr
Definition: ELFYAML.h:91
static void bitset(IO &IO, ELFYAML::ELF_PF &Value)
Definition: ELFYAML.cpp:502
std::vector< SectionName > Sections
Definition: ELFYAML.h:96
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:295
Optional< llvm::yaml::Hex64 > Size
Definition: ELFYAML.h:179
ELFYAML::ELF_REL Type3
Definition: ELFYAML.cpp:1176
llvm::yaml::Hex64 Info
Definition: ELFYAML.h:243
llvm::yaml::Hex64 Address
Definition: ELFYAML.h:137
static void enumeration(IO &IO, ELFYAML::ELF_RSS &Value)
Definition: ELFYAML.cpp:603
FileHeader Header
Definition: ELFYAML.h:315
static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value)
Definition: ELFYAML.cpp:434
llvm::yaml::Hex64 Entry
Definition: ELFYAML.h:75
static void bitset(IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value)
Definition: ELFYAML.cpp:808
llvm::yaml::Hex64 AddressAlign
Definition: ELFYAML.h:139
llvm::yaml::Hex64 Size
Definition: ELFYAML.h:190
std::vector< DynamicEntry > Entries
Definition: ELFYAML.h:167
StringRef Section
Definition: ELFYAML.h:103
static void groupSectionMapping(IO &IO, ELFYAML::Group &Group)
Definition: ELFYAML.cpp:1043
static void enumeration(IO &IO, ELFYAML::ELF_EM &Value)
Definition: ELFYAML.cpp:61
llvm::yaml::Hex64 Size
Definition: ELFYAML.h:107
std::vector< Symbol > Symbols
Definition: ELFYAML.h:322
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:140
llvm::yaml::Hex8 ABIVersion
Definition: ELFYAML.h:71
llvm::yaml::Hex64 Info
Definition: ELFYAML.h:214
Key
PAL metadata keys.
static void enumeration(IO &IO, ELFYAML::ELF_ELFCLASS &Value)
Definition: ELFYAML.cpp:226
Optional< llvm::yaml::Hex64 > EntSize
Definition: ELFYAML.h:140
ELFYAML::ELF_RSS SpecSym
Definition: ELFYAML.cpp:1177
static StringRef input(StringRef Scalar, void *, StOtherPiece &Val)
Definition: ELFYAML.cpp:851
static void output(const StOtherPiece &Val, void *, raw_ostream &Out)
Definition: ELFYAML.cpp:848
iterator find(const KeyT &Key)
Definition: MapVector.h:147
static void enumeration(IO &IO, ELFYAML::MIPS_ISA &Value)
Definition: ELFYAML.cpp:778
Optional< uint8_t > Other
Definition: ELFYAML.h:108
Optional< llvm::yaml::Hex64 > ShSize
Definition: ELFYAML.h:163
std::vector< ProgramHeader > ProgramHeaders
Definition: ELFYAML.h:316
std::vector< VernauxEntry > AuxV
Definition: ELFYAML.h:209
static void commonSectionMapping(IO &IO, ELFYAML::Section &Section)
Definition: ELFYAML.cpp:983
#define P(N)
static void enumeration(IO &IO, ELFYAML::ELF_PT &Value)
Definition: ELFYAML.cpp:43
Optional< llvm::yaml::Hex16 > SHStrNdx
Definition: ELFYAML.h:80
std::string UnknownFlagsHolder
Definition: ELFYAML.cpp:949
* 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:45
static void enumeration(IO &IO, ELFYAML::ELF_DYNTAG &Value)
Definition: ELFYAML.cpp:660
llvm::yaml::Hex32 Flags2
Definition: ELFYAML.h:305
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define BCase(X)
static void enumeration(IO &IO, ELFYAML::ELF_REL &Value)
Definition: ELFYAML.cpp:613
std::vector< uint32_t > Entries
Definition: ELFYAML.h:284
Optional< llvm::yaml::Hex64 > SHOff
Definition: ELFYAML.h:78
std::vector< VerneedEntry > VerneedV
Definition: ELFYAML.h:213
std::vector< StringRef > VerNames
Definition: ELFYAML.h:238
StringRef Signature
Definition: ELFYAML.h:256
static QuotingType mustQuote(StringRef)
Definition: ELFYAML.cpp:855
static void sectionMapping(IO &IO, ELFYAML::DynamicSection &Section)
Definition: ELFYAML.cpp:1002
std::vector< std::unique_ptr< Section > > Sections
Definition: ELFYAML.h:317
Optional< yaml::BinaryRef > Content
Definition: ELFYAML.h:178
Optional< yaml::BinaryRef > Content
Definition: ELFYAML.h:168
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
llvm::yaml::Hex8 ISARevision
Definition: ELFYAML.h:297
Optional< llvm::yaml::Hex64 > MemSize
Definition: ELFYAML.h:94
static void bitset(IO &IO, ELFYAML::ELF_EF &Value)
Definition: ELFYAML.cpp:277
ELF_ELFCLASS Class
Definition: ELFYAML.h:68
std::vector< SectionOrType > Members
Definition: ELFYAML.h:255
Optional< llvm::yaml::Hex64 > ShOffset
Definition: ELFYAML.h:159
llvm::yaml::Hex64 Offset
Definition: ELFYAML.h:266
static uint32_t getFlags(const Symbol *Sym)
Definition: TapiFile.cpp:28
std::vector< Symbol > DynamicSymbols
Definition: ELFYAML.h:323
static void enumeration(IO &IO, ELFYAML::ELF_ELFOSABI &Value)
Definition: ELFYAML.cpp:247
Optional< llvm::yaml::Hex16 > SHNum
Definition: ELFYAML.h:79
static void bitset(IO &IO, ELFYAML::MIPS_AFL_ASE &Value)
Definition: ELFYAML.cpp:789
Optional< llvm::yaml::Hex64 > Info
Definition: ELFYAML.h:180
Optional< llvm::yaml::Hex64 > ShName
Definition: ELFYAML.h:155
static void enumeration(IO &IO, ELFYAML::MIPS_AFL_EXT &Value)
Definition: ELFYAML.cpp:752
#define ECase(X)
bool hasValue() const
Definition: Optional.h:259
ELFYAML::ELF_REL Type2
Definition: ELFYAML.cpp:1175
static void enumeration(IO &IO, ELFYAML::MIPS_ABI_FP &Value)
Definition: ELFYAML.cpp:738
MIPS_AFL_EXT ISAExtension
Definition: ELFYAML.h:302
llvm::yaml::Hex64 Value
Definition: ELFYAML.h:106
static void enumeration(IO &IO, ELFYAML::ELF_STB &Value)
Definition: ELFYAML.cpp:576
static void enumeration(IO &IO, ELFYAML::ELF_ELFDATA &Value)
Definition: ELFYAML.cpp:236
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:332
Optional< llvm::yaml::Hex64 > FileSize
Definition: ELFYAML.h:93
std::vector< VerdefEntry > Entries
Definition: ELFYAML.h:242
const std::string to_string(const T &Value)
Definition: ScopedPrinter.h:61
Optional< llvm::yaml::Hex16 > SHEntSize
Definition: ELFYAML.h:77
Optional< uint32_t > NameIndex
Definition: ELFYAML.h:101
MIPS_AFL_FLAGS1 Flags1
Definition: ELFYAML.h:304
IO & YamlIO
Definition: ELFYAML.cpp:947
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:73
llvm::yaml::Hex64 Val
Definition: ELFYAML.h:117
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
std::vector< uint16_t > Entries
Definition: ELFYAML.h:224
static void enumeration(IO &IO, ELFYAML::MIPS_AFL_REG &Value)
Definition: ELFYAML.cpp:728
ELF_ELFOSABI OSABI
Definition: ELFYAML.h:70
llvm::yaml::Hex64 VAddr
Definition: ELFYAML.h:90
#define BCaseMask(X, M)
Optional< StringRef > Symbol
Definition: ELFYAML.h:269
std::vector< Relocation > Relocations
Definition: ELFYAML.h:273
void validate(const Triple &TT, const FeatureBitset &FeatureBits)
Optional< llvm::yaml::Hex64 > Offset
Definition: ELFYAML.h:95