32 IO &IO, ELFYAML::ELF_ET &
Value) {
33 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 40 IO.enumFallback<Hex16>(
Value);
44 IO &IO, ELFYAML::ELF_PT &
Value) {
45 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 59 IO.enumFallback<Hex32>(
Value);
63 IO &IO, ELFYAML::ELF_EM &
Value) {
64 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 225 IO.enumFallback<Hex16>(
Value);
229 IO &IO, ELFYAML::ELF_ELFCLASS &
Value) {
230 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 239 IO &IO, ELFYAML::ELF_ELFDATA &
Value) {
240 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 250 IO &IO, ELFYAML::ELF_ELFOSABI &
Value) {
251 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 278 IO.enumFallback<Hex8>(
Value);
282 ELFYAML::ELF_EF &
Value) {
284 assert(Object &&
"The IO context is not initialized");
285 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X) 286 #define BCaseMask(X, M) IO.maskedBitSetCase(Value, #X, ELF::X, ELF::M) 287 switch (Object->Header.Machine) {
439 IO &IO, ELFYAML::ELF_SHT &
Value) {
441 assert(Object &&
"The IO context is not initialized");
442 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 478 switch (Object->Header.Machine) {
503 IO.enumFallback<Hex32>(
Value);
507 ELFYAML::ELF_PF &
Value) {
508 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X) 515 ELFYAML::ELF_SHF &
Value) {
517 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X) 530 switch (Object->Header.Machine) {
558 IO &IO, ELFYAML::ELF_SHN &
Value) {
559 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 577 IO.enumFallback<Hex16>(
Value);
581 IO &IO, ELFYAML::ELF_STB &
Value) {
582 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 588 IO.enumFallback<Hex8>(
Value);
592 IO &IO, ELFYAML::ELF_STT &
Value) {
593 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 603 IO.enumFallback<Hex8>(
Value);
608 IO &IO, ELFYAML::ELF_RSS &
Value) {
609 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 618 IO &IO, ELFYAML::ELF_REL &
Value) {
620 assert(Object &&
"The IO context is not initialized");
621 #define ELF_RELOC(X, Y) IO.enumCase(Value, #X, ELF::X); 622 switch (Object->Header.Machine) {
624 #include "llvm/BinaryFormat/ELFRelocs/x86_64.def" 627 #include "llvm/BinaryFormat/ELFRelocs/Mips.def" 630 #include "llvm/BinaryFormat/ELFRelocs/Hexagon.def" 634 #include "llvm/BinaryFormat/ELFRelocs/i386.def" 637 #include "llvm/BinaryFormat/ELFRelocs/AArch64.def" 640 #include "llvm/BinaryFormat/ELFRelocs/ARM.def" 643 #include "llvm/BinaryFormat/ELFRelocs/ARC.def" 646 #include "llvm/BinaryFormat/ELFRelocs/RISCV.def" 649 #include "llvm/BinaryFormat/ELFRelocs/Lanai.def" 652 #include "llvm/BinaryFormat/ELFRelocs/AMDGPU.def" 655 #include "llvm/BinaryFormat/ELFRelocs/BPF.def" 658 #include "llvm/BinaryFormat/ELFRelocs/PowerPC64.def" 665 IO.enumFallback<Hex32>(
Value);
669 IO &IO, ELFYAML::ELF_DYNTAG &
Value) {
671 assert(Object &&
"The IO context is not initialized");
674 #define AARCH64_DYNAMIC_TAG(name, value) 675 #define MIPS_DYNAMIC_TAG(name, value) 676 #define HEXAGON_DYNAMIC_TAG(name, value) 677 #define PPC_DYNAMIC_TAG(name, value) 678 #define PPC64_DYNAMIC_TAG(name, value) 680 #define DYNAMIC_TAG_MARKER(name, value) 682 #define STRINGIFY(X) (#X) 683 #define DYNAMIC_TAG(X, Y) IO.enumCase(Value, STRINGIFY(DT_##X), ELF::DT_##X); 684 switch (Object->Header.Machine) {
686 #undef AARCH64_DYNAMIC_TAG 687 #define AARCH64_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value) 688 #include "llvm/BinaryFormat/DynamicTags.def" 689 #undef AARCH64_DYNAMIC_TAG 690 #define AARCH64_DYNAMIC_TAG(name, value) 693 #undef MIPS_DYNAMIC_TAG 694 #define MIPS_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value) 695 #include "llvm/BinaryFormat/DynamicTags.def" 696 #undef MIPS_DYNAMIC_TAG 697 #define MIPS_DYNAMIC_TAG(name, value) 700 #undef HEXAGON_DYNAMIC_TAG 701 #define HEXAGON_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value) 702 #include "llvm/BinaryFormat/DynamicTags.def" 703 #undef HEXAGON_DYNAMIC_TAG 704 #define HEXAGON_DYNAMIC_TAG(name, value) 707 #undef PPC_DYNAMIC_TAG 708 #define PPC_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value) 709 #include "llvm/BinaryFormat/DynamicTags.def" 710 #undef PPC_DYNAMIC_TAG 711 #define PPC_DYNAMIC_TAG(name, value) 714 #undef PPC64_DYNAMIC_TAG 715 #define PPC64_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value) 716 #include "llvm/BinaryFormat/DynamicTags.def" 717 #undef PPC64_DYNAMIC_TAG 718 #define PPC64_DYNAMIC_TAG(name, value) 721 #include "llvm/BinaryFormat/DynamicTags.def" 724 #undef AARCH64_DYNAMIC_TAG 725 #undef MIPS_DYNAMIC_TAG 726 #undef HEXAGON_DYNAMIC_TAG 727 #undef PPC_DYNAMIC_TAG 728 #undef PPC64_DYNAMIC_TAG 729 #undef DYNAMIC_TAG_MARKER 733 IO.enumFallback<Hex64>(
Value);
737 IO &IO, ELFYAML::MIPS_AFL_REG &
Value) {
738 #define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X) 747 IO &IO, ELFYAML::MIPS_ABI_FP &
Value) {
748 #define ECase(X) IO.enumCase(Value, #X, Mips::Val_GNU_MIPS_ABI_##X) 761 IO &IO, ELFYAML::MIPS_AFL_EXT &
Value) {
762 #define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X) 767 ECase(EXT_LOONGSON_3A);
780 ECase(EXT_LOONGSON_2E);
781 ECase(EXT_LOONGSON_2F);
787 IO &IO, ELFYAML::MIPS_ISA &
Value) {
788 IO.enumCase(Value,
"MIPS1", 1);
789 IO.enumCase(Value,
"MIPS2", 2);
790 IO.enumCase(Value,
"MIPS3", 3);
791 IO.enumCase(Value,
"MIPS4", 4);
792 IO.enumCase(Value,
"MIPS5", 5);
793 IO.enumCase(Value,
"MIPS32", 32);
794 IO.enumCase(Value,
"MIPS64", 64);
798 IO &IO, ELFYAML::MIPS_AFL_ASE &
Value) {
799 #define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_ASE_##X) 817 IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &
Value) {
818 #define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_FLAGS1_##X) 825 IO.mapRequired(
"Class", FileHdr.
Class);
826 IO.mapRequired(
"Data", FileHdr.
Data);
827 IO.mapOptional(
"OSABI", FileHdr.
OSABI, ELFYAML::ELF_ELFOSABI(0));
828 IO.mapOptional(
"ABIVersion", FileHdr.
ABIVersion, Hex8(0));
829 IO.mapRequired(
"Type", FileHdr.
Type);
830 IO.mapRequired(
"Machine", FileHdr.
Machine);
831 IO.mapOptional(
"Flags", FileHdr.
Flags, ELFYAML::ELF_EF(0));
832 IO.mapOptional(
"Entry", FileHdr.
Entry, Hex64(0));
834 IO.mapOptional(
"SHEntSize", FileHdr.
SHEntSize);
835 IO.mapOptional(
"SHOff", FileHdr.
SHOff);
836 IO.mapOptional(
"SHNum", FileHdr.
SHNum);
837 IO.mapOptional(
"SHStrNdx", FileHdr.
SHStrNdx);
842 IO.mapRequired(
"Type", Phdr.
Type);
843 IO.mapOptional(
"Flags", Phdr.
Flags, ELFYAML::ELF_PF(0));
844 IO.mapOptional(
"Sections", Phdr.
Sections);
845 IO.mapOptional(
"VAddr", Phdr.
VAddr, Hex64(0));
846 IO.mapOptional(
"PAddr", Phdr.
PAddr, Hex64(0));
847 IO.mapOptional(
"Align", Phdr.
Align);
848 IO.mapOptional(
"FileSize", Phdr.
FileSize);
849 IO.mapOptional(
"MemSize", Phdr.
MemSize);
850 IO.mapOptional(
"Offset", Phdr.
Offset);
853 LLVM_YAML_STRONG_TYPEDEF(
StringRef, StOtherPiece)
855 template <> struct ScalarTraits<StOtherPiece> {
865 template <>
struct SequenceElementTraits<StOtherPiece> {
866 static const bool flow =
true;
869 template <>
struct ScalarTraits<ELFYAML::YAMLFlowString> {
870 static void output(
const ELFYAML::YAMLFlowString &Val,
void *,
875 ELFYAML::YAMLFlowString &Val) {
880 return ScalarTraits<StringRef>::mustQuote(S);
883 template <>
struct SequenceElementTraits<ELFYAML::YAMLFlowString> {
884 static const bool flow =
true;
889 struct NormalizedOther {
890 NormalizedOther(IO &IO) :
YamlIO(IO) {}
892 assert(Original &&
"This constructor is only used for outputting YAML and " 893 "assumes a non-empty Original");
894 std::vector<StOtherPiece>
Ret;
896 for (std::pair<StringRef, uint8_t> &
P :
897 getFlags(Object->Header.Machine).takeVector()) {
898 uint8_t FlagValue =
P.second;
899 if ((*Original & FlagValue) != FlagValue)
901 *Original &= ~FlagValue;
902 Ret.push_back({
P.first});
905 if (*Original != 0) {
911 Other = std::move(Ret);
918 auto It = Flags.
find(Name);
919 if (It != Flags.
end())
926 YamlIO.setError(
"an unknown value is used for symbol's 'Other' field: " +
935 for (StOtherPiece &Val : *
Other)
974 Optional<std::vector<StOtherPiece>>
Other;
982 IO.mapOptional(
"NameIndex", Symbol.
NameIndex);
983 IO.mapOptional(
"Type", Symbol.
Type, ELFYAML::ELF_STT(0));
985 IO.mapOptional(
"Index", Symbol.
Index);
986 IO.mapOptional(
"Binding", Symbol.
Binding, ELFYAML::ELF_STB(0));
987 IO.mapOptional(
"Value", Symbol.
Value, Hex64(0));
988 IO.mapOptional(
"Size", Symbol.
Size, Hex64(0));
995 MappingNormalization<NormalizedOther, Optional<uint8_t>> Keys(IO,
997 IO.mapOptional(
"Other", Keys->Other);
1003 return "Index and Section cannot both be specified for Symbol";
1005 return "Name and NameIndex cannot both be specified for Symbol";
1011 IO.mapRequired(
"Type", Section.
Type);
1012 IO.mapOptional(
"Flags", Section.
Flags);
1013 IO.mapOptional(
"Address", Section.
Address, Hex64(0));
1015 IO.mapOptional(
"AddressAlign", Section.
AddressAlign, Hex64(0));
1016 IO.mapOptional(
"EntSize", Section.
EntSize);
1021 assert(!IO.outputting() ||
1024 IO.mapOptional(
"ShName", Section.
ShName);
1025 IO.mapOptional(
"ShOffset", Section.
ShOffset);
1026 IO.mapOptional(
"ShSize", Section.
ShSize);
1027 IO.mapOptional(
"ShFlags", Section.
ShFlags);
1032 IO.mapOptional(
"Entries", Section.
Entries);
1033 IO.mapOptional(
"Content", Section.
Content);
1038 IO.mapOptional(
"Content", Section.
Content);
1039 IO.mapOptional(
"Size", Section.
Size);
1040 IO.mapOptional(
"Info", Section.
Info);
1045 IO.mapOptional(
"Content", Section.
Content);
1046 IO.mapOptional(
"Size", Section.
Size);
1047 IO.mapOptional(
"Entries", Section.
Entries);
1052 IO.mapOptional(
"Content", Section.
Content);
1053 IO.mapOptional(
"Bucket", Section.
Bucket);
1054 IO.mapOptional(
"Chain", Section.
Chain);
1055 IO.mapOptional(
"Size", Section.
Size);
1060 IO.mapOptional(
"Content", Section.
Content);
1061 IO.mapOptional(
"Size", Section.
Size);
1062 IO.mapOptional(
"Notes", Section.
Notes);
1068 IO.mapOptional(
"Content", Section.
Content);
1069 IO.mapOptional(
"Header", Section.
Header);
1070 IO.mapOptional(
"BloomFilter", Section.
BloomFilter);
1071 IO.mapOptional(
"HashBuckets", Section.
HashBuckets);
1072 IO.mapOptional(
"HashValues", Section.
HashValues);
1076 IO.mapOptional(
"Size", Section.
Size, Hex64(0));
1081 IO.mapRequired(
"Info", Section.
Info);
1082 IO.mapOptional(
"Entries", Section.
Entries);
1083 IO.mapOptional(
"Content", Section.
Content);
1088 IO.mapRequired(
"Entries", Section.
Entries);
1093 IO.mapRequired(
"Info", Section.
Info);
1094 IO.mapOptional(
"Dependencies", Section.
VerneedV);
1095 IO.mapOptional(
"Content", Section.
Content);
1101 IO.mapOptional(
"Relocations", Section.
Relocations);
1106 IO.mapOptional(
"Entries", Section.
Entries);
1107 IO.mapOptional(
"Content", Section.
Content);
1112 IO.mapOptional(
"Info", Group.
Signature);
1113 IO.mapRequired(
"Members", Group.
Members);
1118 IO.mapRequired(
"Entries", Section.
Entries);
1123 IO.mapOptional(
"Content", Section.
Content);
1124 IO.mapOptional(
"Size", Section.
Size);
1125 IO.mapOptional(
"Symbols", Section.
Symbols);
1130 IO.mapOptional(
"Pattern", Fill.
Pattern);
1131 IO.mapRequired(
"Size", Fill.
Size);
1136 IO.mapOptional(
"Options", Section.
Options);
1137 IO.mapOptional(
"Content", Section.
Content);
1143 IO.mapOptional(
"Libraries", Section.
Libs);
1144 IO.mapOptional(
"Content", Section.
Content);
1154 IO.mapRequired(
"Section", sectionName.
Section);
1159 IO.mapOptional(
"Version", Section.
Version, Hex16(0));
1160 IO.mapRequired(
"ISA", Section.
ISALevel);
1161 IO.mapOptional(
"ISARevision", Section.
ISARevision, Hex8(0));
1164 IO.mapOptional(
"ASEs", Section.
ASEs, ELFYAML::MIPS_AFL_ASE(0));
1165 IO.mapOptional(
"FpABI", Section.
FpABI,
1167 IO.mapOptional(
"GPRSize", Section.
GPRSize,
1169 IO.mapOptional(
"CPR1Size", Section.
CPR1Size,
1171 IO.mapOptional(
"CPR2Size", Section.
CPR2Size,
1173 IO.mapOptional(
"Flags1", Section.
Flags1, ELFYAML::MIPS_AFL_FLAGS1(0));
1174 IO.mapOptional(
"Flags2", Section.
Flags2, Hex32(0));
1178 IO &IO, std::unique_ptr<ELFYAML::Chunk> &
Section) {
1179 ELFYAML::ELF_SHT
Type;
1180 if (IO.outputting()) {
1181 Type = cast<ELFYAML::Section>(Section.get())->Type;
1187 IO.mapRequired(
"Type", StrType);
1188 if (StrType ==
"Fill") {
1190 fillMapping(IO, *cast<ELFYAML::Fill>(Section.get()));
1194 IO.mapRequired(
"Type", Type);
1199 if (!IO.outputting())
1201 sectionMapping(IO, *cast<ELFYAML::DynamicSection>(Section.get()));
1205 if (!IO.outputting())
1207 sectionMapping(IO, *cast<ELFYAML::RelocationSection>(Section.get()));
1210 if (!IO.outputting())
1215 if (!IO.outputting())
1220 if (!IO.outputting())
1222 sectionMapping(IO, *cast<ELFYAML::NoBitsSection>(Section.get()));
1225 if (!IO.outputting())
1230 if (!IO.outputting())
1235 if (!IO.outputting())
1237 sectionMapping(IO, *cast<ELFYAML::GnuHashSection>(Section.get()));
1240 if (!IO.outputting())
1245 if (!IO.outputting())
1247 sectionMapping(IO, *cast<ELFYAML::VerdefSection>(Section.get()));
1250 if (!IO.outputting())
1252 sectionMapping(IO, *cast<ELFYAML::SymverSection>(Section.get()));
1255 if (!IO.outputting())
1257 sectionMapping(IO, *cast<ELFYAML::VerneedSection>(Section.get()));
1260 if (!IO.outputting())
1262 sectionMapping(IO, *cast<ELFYAML::SymtabShndxSection>(Section.get()));
1265 if (!IO.outputting())
1267 sectionMapping(IO, *cast<ELFYAML::AddrsigSection>(Section.get()));
1270 if (!IO.outputting())
1272 sectionMapping(IO, *cast<ELFYAML::LinkerOptionsSection>(Section.get()));
1275 if (!IO.outputting())
1278 *cast<ELFYAML::DependentLibrariesSection>(Section.get()));
1281 if (!IO.outputting()) {
1283 IO.mapOptional(
"Name", Name,
StringRef());
1287 Section = std::make_unique<ELFYAML::StackSizesSection>();
1289 Section = std::make_unique<ELFYAML::RawContentSection>();
1292 if (
auto S = dyn_cast<ELFYAML::RawContentSection>(Section.get()))
1295 sectionMapping(IO, *cast<ELFYAML::StackSizesSection>(Section.get()));
1300 IO &io, std::unique_ptr<ELFYAML::Chunk> &
C) {
1301 if (
const auto *RawSection = dyn_cast<ELFYAML::RawContentSection>(C.get())) {
1302 if (RawSection->Size && RawSection->Content &&
1303 (uint64_t)(*RawSection->Size) < RawSection->Content->binary_size())
1304 return "Section size must be greater than or equal to the content size";
1305 if (RawSection->Flags && RawSection->ShFlags)
1306 return "ShFlags and Flags cannot be used together";
1310 if (
const auto *
SS = dyn_cast<ELFYAML::StackSizesSection>(C.get())) {
1311 if (!
SS->Entries && !
SS->Content && !
SS->Size)
1312 return ".stack_sizes: one of Content, Entries and Size must be specified";
1314 if (
SS->Size &&
SS->Content &&
1315 (uint64_t)(*
SS->Size) <
SS->Content->binary_size())
1316 return ".stack_sizes: Size must be greater than or equal to the content " 1324 return ".stack_sizes: Size and Entries cannot be used together";
1326 return ".stack_sizes: Content and Entries cannot be used together";
1330 if (
const auto *
HS = dyn_cast<ELFYAML::HashSection>(C.get())) {
1331 if (!
HS->Content && !
HS->Bucket && !
HS->Chain && !
HS->Size)
1332 return "one of \"Content\", \"Size\", \"Bucket\" or \"Chain\" must be " 1335 if (
HS->Content ||
HS->Size) {
1336 if (
HS->Size &&
HS->Content &&
1337 (uint64_t)*
HS->Size <
HS->Content->binary_size())
1338 return "\"Size\" must be greater than or equal to the content " 1342 return "\"Bucket\" cannot be used with \"Content\" or \"Size\"";
1344 return "\"Chain\" cannot be used with \"Content\" or \"Size\"";
1348 if ((
HS->Bucket && !
HS->Chain) || (!
HS->Bucket &&
HS->Chain))
1349 return "\"Bucket\" and \"Chain\" must be used together";
1353 if (
const auto *Sec = dyn_cast<ELFYAML::AddrsigSection>(C.get())) {
1354 if (!Sec->Symbols && !Sec->Content && !Sec->Size)
1355 return "one of \"Content\", \"Size\" or \"Symbols\" must be specified";
1357 if (Sec->Content || Sec->Size) {
1358 if (Sec->Size && Sec->Content &&
1359 (uint64_t)*Sec->Size < Sec->Content->binary_size())
1360 return "\"Size\" must be greater than or equal to the content " 1364 return "\"Symbols\" cannot be used with \"Content\" or \"Size\"";
1373 return "\"Index\" and \"Name\" cannot be used together when defining a " 1378 if (
const auto *NS = dyn_cast<ELFYAML::NoteSection>(C.get())) {
1379 if (!NS->Content && !NS->Size && !NS->Notes)
1380 return "one of \"Content\", \"Size\" or \"Notes\" must be " 1383 if (!NS->Content && !NS->Size)
1386 if (NS->Size && NS->Content &&
1387 (uint64_t)*NS->Size < NS->Content->binary_size())
1388 return "\"Size\" must be greater than or equal to the content " 1392 return "\"Notes\" cannot be used with \"Content\" or \"Size\"";
1396 if (
const auto *Sec = dyn_cast<ELFYAML::GnuHashSection>(C.get())) {
1397 if (!Sec->Content && !Sec->Header && !Sec->BloomFilter &&
1398 !Sec->HashBuckets && !Sec->HashValues)
1399 return "either \"Content\" or \"Header\", \"BloomFilter\", " 1400 "\"HashBuckets\" and \"HashBuckets\" must be specified";
1402 if (Sec->Header || Sec->BloomFilter || Sec->HashBuckets ||
1404 if (!Sec->Header || !Sec->BloomFilter || !Sec->HashBuckets ||
1406 return "\"Header\", \"BloomFilter\", " 1407 "\"HashBuckets\" and \"HashValues\" must be used together";
1409 return "\"Header\", \"BloomFilter\", " 1410 "\"HashBuckets\" and \"HashValues\" can't be used together with " 1419 if (
const auto *Sec = dyn_cast<ELFYAML::LinkerOptionsSection>(C.get())) {
1420 if (Sec->Options && Sec->Content)
1421 return "\"Options\" and \"Content\" can't be used together";
1425 if (
const auto *Sec = dyn_cast<ELFYAML::DependentLibrariesSection>(C.get())) {
1426 if (Sec->Libs && Sec->Content)
1427 return "SHT_LLVM_DEPENDENT_LIBRARIES: \"Libraries\" and \"Content\" " 1433 if (
const auto *
F = dyn_cast<ELFYAML::Fill>(C.get())) {
1436 if (
F->Pattern->binary_size() != 0 && !
F->Size)
1437 return "\"Size\" can't be 0 when \"Pattern\" is not empty";
1441 if (
const auto *VD = dyn_cast<ELFYAML::VerdefSection>(C.get())) {
1442 if (VD->Entries && VD->Content)
1443 return "SHT_GNU_verdef: \"Entries\" and \"Content\" can't be used " 1448 if (
const auto *VD = dyn_cast<ELFYAML::VerneedSection>(C.get())) {
1449 if (VD->VerneedV && VD->Content)
1450 return "SHT_GNU_verneed: \"Dependencies\" and \"Content\" can't be used " 1455 if (
const auto *RS = dyn_cast<ELFYAML::RelrSection>(C.get())) {
1456 if (RS->Entries && RS->Content)
1457 return "\"Entries\" and \"Content\" can't be used together";
1466 struct NormalizedMips64RelType {
1467 NormalizedMips64RelType(IO &)
1468 :
Type(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
1469 Type2(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
1470 Type3(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
1472 NormalizedMips64RelType(IO &, ELFYAML::ELF_REL Original)
1473 :
Type(Original & 0xFF),
Type2(Original >> 8 & 0xFF),
1474 Type3(Original >> 16 & 0xFF),
SpecSym(Original >> 24 & 0xFF) {}
1476 ELFYAML::ELF_REL denormalize(IO &) {
1481 ELFYAML::ELF_REL Type;
1491 assert(IO.getContext() &&
"The IO context is not initialized");
1492 IO.mapOptional(
"Address", E.
Address, Hex64(0));
1493 IO.mapRequired(
"Size", E.
Size);
1498 assert(IO.getContext() &&
"The IO context is not initialized");
1499 IO.mapOptional(
"NBuckets", E.
NBuckets);
1500 IO.mapRequired(
"SymNdx", E.
SymNdx);
1501 IO.mapOptional(
"MaskWords", E.
MaskWords);
1502 IO.mapRequired(
"Shift2", E.
Shift2);
1507 assert(IO.getContext() &&
"The IO context is not initialized");
1509 IO.mapRequired(
"Tag", Rel.
Tag);
1510 IO.mapRequired(
"Value", Rel.
Val);
1514 assert(IO.getContext() &&
"The IO context is not initialized");
1516 IO.mapOptional(
"Name", N.
Name);
1517 IO.mapOptional(
"Desc", N.
Desc);
1518 IO.mapRequired(
"Type", N.
Type);
1523 assert(IO.getContext() &&
"The IO context is not initialized");
1525 IO.mapRequired(
"Version", E.
Version);
1526 IO.mapRequired(
"Flags", E.
Flags);
1528 IO.mapRequired(
"Hash", E.
Hash);
1529 IO.mapRequired(
"Names", E.
VerNames);
1534 assert(IO.getContext() &&
"The IO context is not initialized");
1536 IO.mapRequired(
"Version", E.
Version);
1537 IO.mapRequired(
"File", E.
File);
1538 IO.mapRequired(
"Entries", E.
AuxV);
1543 assert(IO.getContext() &&
"The IO context is not initialized");
1545 IO.mapRequired(
"Name", E.
Name);
1546 IO.mapRequired(
"Hash", E.
Hash);
1547 IO.mapRequired(
"Flags", E.
Flags);
1548 IO.mapRequired(
"Other", E.
Other);
1554 assert(Object &&
"The IO context is not initialized");
1556 IO.mapRequired(
"Offset", Rel.
Offset);
1557 IO.mapOptional(
"Symbol", Rel.
Symbol);
1559 if (Object->Header.Machine == ELFYAML::ELF_EM(
ELF::EM_MIPS) &&
1561 MappingNormalization<NormalizedMips64RelType, ELFYAML::ELF_REL>
Key(
1563 IO.mapRequired(
"Type", Key->Type);
1564 IO.mapOptional(
"Type2", Key->Type2, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
1565 IO.mapOptional(
"Type3", Key->Type3, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
1566 IO.mapOptional(
"SpecSym", Key->SpecSym, ELFYAML::ELF_RSS(
ELF::RSS_UNDEF));
1568 IO.mapRequired(
"Type", Rel.
Type);
1570 IO.mapOptional(
"Addend", Rel.
Addend, (int64_t)0);
1574 assert(!IO.getContext() &&
"The IO context is initialized already");
1575 IO.setContext(&Object);
1576 IO.mapTag(
"!ELF",
true);
1577 IO.mapRequired(
"FileHeader", Object.
Header);
1579 IO.mapOptional(
"Sections", Object.
Chunks);
1580 IO.mapOptional(
"Symbols", Object.
Symbols);
1582 IO.setContext(
nullptr);
1586 assert(IO.getContext() &&
"The IO context is not initialized");
1587 IO.mapOptional(
"Name", Sym.
Name);
1588 IO.mapOptional(
"Index", Sym.
Index);
1593 assert(IO.getContext() &&
"The IO context is not initialized");
1594 IO.mapRequired(
"Name", Opt.
Key);
1595 IO.mapRequired(
"Value", Opt.
Value);
1598 LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_AFL_REG)
1599 LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_ABI_FP)
1600 LLVM_YAML_STRONG_TYPEDEF(
uint32_t, MIPS_AFL_EXT)
1601 LLVM_YAML_STRONG_TYPEDEF(
uint32_t, MIPS_AFL_ASE)
1602 LLVM_YAML_STRONG_TYPEDEF(
uint32_t, MIPS_AFL_FLAGS1)
This file declares classes for handling the YAML representation of ELF.
static StringRef input(StringRef Scalar, void *, ELFYAML::YAMLFlowString &Val)
static void bitset(IO &IO, ELFYAML::ELF_SHF &Value)
Optional< ELF_SHF > Flags
Optional< llvm::yaml::Hex64 > Size
This class represents lattice values for constants.
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.
Optional< std::vector< llvm::yaml::Hex64 > > BloomFilter
Optional< yaml::BinaryRef > Content
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
Optional< yaml::BinaryRef > Content
Optional< std::vector< Symbol > > DynamicSymbols
static void enumeration(IO &IO, ELFYAML::ELF_ET &Value)
static void enumeration(IO &IO, ELFYAML::ELF_STT &Value)
Optional< ELF_SHN > Index
static void enumeration(IO &IO, ELFYAML::ELF_SHN &Value)
Optional< llvm::yaml::Hex64 > Size
Optional< std::vector< StOtherPiece > > Other
static QuotingType mustQuote(StringRef S)
static void bitset(IO &IO, ELFYAML::ELF_PF &Value)
This class implements a map that also provides access to all stored values in a deterministic order...
llvm::yaml::Hex16 Version
Optional< llvm::yaml::Hex64 > Size
llvm::yaml::Hex64 Address
static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value)
Optional< llvm::yaml::Hex64 > Size
static void bitset(IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value)
llvm::yaml::Hex64 AddressAlign
Optional< llvm::yaml::Hex32 > Index
Optional< std::vector< llvm::yaml::Hex32 > > HashValues
std::vector< DynamicEntry > Entries
Optional< StringRef > Signature
Optional< std::vector< StackSizeEntry > > Entries
static void groupSectionMapping(IO &IO, ELFYAML::Group &Group)
static void enumeration(IO &IO, ELFYAML::ELF_EM &Value)
Optional< std::vector< uint32_t > > Chain
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
StringRef sectionNameOrType
static void enumeration(IO &IO, ELFYAML::ELF_ELFCLASS &Value)
Optional< llvm::yaml::Hex64 > EntSize
static StringRef input(StringRef Scalar, void *, StOtherPiece &Val)
std::vector< std::unique_ptr< Chunk > > Chunks
static void output(const StOtherPiece &Val, void *, raw_ostream &Out)
Optional< GnuHashHeader > Header
iterator find(const KeyT &Key)
static void enumeration(IO &IO, ELFYAML::MIPS_ISA &Value)
Optional< uint8_t > Other
Optional< llvm::yaml::Hex64 > ShSize
std::vector< ProgramHeader > ProgramHeaders
Optional< std::vector< Symbol > > Symbols
std::vector< VernauxEntry > AuxV
static void commonSectionMapping(IO &IO, ELFYAML::Section &Section)
static void enumeration(IO &IO, ELFYAML::ELF_PT &Value)
std::string UnknownFlagsHolder
* 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...
static void enumeration(IO &IO, ELFYAML::ELF_DYNTAG &Value)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static void enumeration(IO &IO, ELFYAML::ELF_REL &Value)
std::vector< uint32_t > Entries
Optional< llvm::yaml::Hex64 > Size
std::vector< StringRef > VerNames
Optional< yaml::BinaryRef > Content
static QuotingType mustQuote(StringRef)
static void sectionMapping(IO &IO, ELFYAML::DynamicSection &Section)
Optional< std::vector< ELFYAML::NoteEntry > > Notes
Optional< yaml::BinaryRef > Content
Optional< yaml::BinaryRef > Content
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
llvm::yaml::Hex8 ISARevision
Optional< std::vector< LinkerOption > > Options
Optional< std::vector< llvm::yaml::Hex64 > > Entries
StringRef dropUniqueSuffix(StringRef S)
static void bitset(IO &IO, ELFYAML::ELF_EF &Value)
std::vector< SectionOrType > Members
Optional< llvm::yaml::Hex64 > ShOffset
Optional< StringRef > Name
static bool nameMatches(StringRef Name)
Optional< yaml::BinaryRef > Content
static uint32_t getFlags(const Symbol *Sym)
Optional< std::vector< VerneedEntry > > VerneedV
static void enumeration(IO &IO, ELFYAML::ELF_ELFOSABI &Value)
static void bitset(IO &IO, ELFYAML::MIPS_AFL_ASE &Value)
Optional< llvm::yaml::Hex64 > Info
Optional< llvm::yaml::Hex64 > ShName
static void enumeration(IO &IO, ELFYAML::MIPS_AFL_EXT &Value)
Optional< llvm::yaml::Hex64 > ShFlags
llvm::yaml::Hex64 Address
Optional< yaml::BinaryRef > Pattern
static void enumeration(IO &IO, ELFYAML::MIPS_ABI_FP &Value)
Optional< yaml::BinaryRef > Content
MIPS_AFL_EXT ISAExtension
Optional< std::vector< uint32_t > > Bucket
Optional< std::vector< llvm::yaml::Hex32 > > HashBuckets
static void enumeration(IO &IO, ELFYAML::ELF_STB &Value)
static void enumeration(IO &IO, ELFYAML::ELF_ELFDATA &Value)
Optional< std::vector< AddrsigSymbol > > Symbols
Optional< yaml::BinaryRef > Content
Optional< yaml::BinaryRef > Content
const std::string to_string(const T &Value)
Optional< uint32_t > NameIndex
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void fillMapping(IO &IO, ELFYAML::Fill &Fill)
LLVM Value Representation.
Optional< yaml::BinaryRef > Content
Optional< std::vector< VerdefEntry > > Entries
This class implements an extremely fast bulk output stream that can only output to a stream...
Optional< std::vector< YAMLFlowString > > Libs
static void output(const ELFYAML::YAMLFlowString &Val, void *, raw_ostream &Out)
StringRef - Represent a constant reference to a string, i.e.
Optional< yaml::BinaryRef > Content
std::vector< uint16_t > Entries
static void enumeration(IO &IO, ELFYAML::MIPS_AFL_REG &Value)
Optional< yaml::BinaryRef > Content
Optional< StringRef > Symbol
std::vector< Relocation > Relocations
void validate(const Triple &TT, const FeatureBitset &FeatureBits)