31 IO &IO, ELFYAML::ELF_ET &
Value) {
32 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 39 IO.enumFallback<Hex16>(Value);
43 IO &IO, ELFYAML::ELF_PT &
Value) {
44 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 55 IO.enumFallback<Hex32>(Value);
59 IO &IO, ELFYAML::ELF_EM &
Value) {
60 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 224 IO &IO, ELFYAML::ELF_ELFCLASS &
Value) {
225 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 234 IO &IO, ELFYAML::ELF_ELFDATA &
Value) {
235 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 244 IO &IO, ELFYAML::ELF_ELFOSABI &
Value) {
245 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 274 ELFYAML::ELF_EF &
Value) {
276 assert(Object &&
"The IO context is not initialized");
277 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X) 278 #define BCaseMask(X, M) IO.maskedBitSetCase(Value, #X, ELF::X, ELF::M) 279 switch (Object->Header.Machine) {
427 IO &IO, ELFYAML::ELF_SHT &
Value) {
429 assert(Object &&
"The IO context is not initialized");
430 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 465 switch (Object->Header.Machine) {
492 ELFYAML::ELF_PF &
Value) {
493 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X) 500 ELFYAML::ELF_SHF &
Value) {
502 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X) 515 switch (Object->Header.Machine) {
543 IO &IO, ELFYAML::ELF_SHN &
Value) {
544 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 561 IO.enumFallback<Hex32>(Value);
565 IO &IO, ELFYAML::ELF_STT &
Value) {
566 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 579 IO &IO, ELFYAML::ELF_STV &
Value) {
580 #define ECase(X) IO.enumCase(Value, #X, ELF::X) 589 ELFYAML::ELF_STO &
Value) {
591 assert(Object &&
"The IO context is not initialized");
592 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X) 593 switch (Object->Header.Machine) {
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" 661 IO.enumFallback<Hex32>(Value);
665 IO &IO, ELFYAML::MIPS_AFL_REG &
Value) {
666 #define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X) 675 IO &IO, ELFYAML::MIPS_ABI_FP &
Value) {
676 #define ECase(X) IO.enumCase(Value, #X, Mips::Val_GNU_MIPS_ABI_##X) 689 IO &IO, ELFYAML::MIPS_AFL_EXT &
Value) {
690 #define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X) 695 ECase(EXT_LOONGSON_3A);
708 ECase(EXT_LOONGSON_2E);
709 ECase(EXT_LOONGSON_2F);
715 IO &IO, ELFYAML::MIPS_ISA &
Value) {
716 IO.enumCase(Value,
"MIPS1", 1);
717 IO.enumCase(Value,
"MIPS2", 2);
718 IO.enumCase(Value,
"MIPS3", 3);
719 IO.enumCase(Value,
"MIPS4", 4);
720 IO.enumCase(Value,
"MIPS5", 5);
721 IO.enumCase(Value,
"MIPS32", 32);
722 IO.enumCase(Value,
"MIPS64", 64);
726 IO &IO, ELFYAML::MIPS_AFL_ASE &
Value) {
727 #define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_ASE_##X) 745 IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &
Value) {
746 #define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_FLAGS1_##X) 753 IO.mapRequired(
"Class", FileHdr.
Class);
754 IO.mapRequired(
"Data", FileHdr.
Data);
755 IO.mapOptional(
"OSABI", FileHdr.
OSABI, ELFYAML::ELF_ELFOSABI(0));
756 IO.mapOptional(
"ABIVersion", FileHdr.
ABIVersion, Hex8(0));
757 IO.mapRequired(
"Type", FileHdr.
Type);
758 IO.mapRequired(
"Machine", FileHdr.
Machine);
759 IO.mapOptional(
"Flags", FileHdr.
Flags, ELFYAML::ELF_EF(0));
760 IO.mapOptional(
"Entry", FileHdr.
Entry, Hex64(0));
765 IO.mapRequired(
"Type", Phdr.
Type);
766 IO.mapOptional(
"Flags", Phdr.
Flags, ELFYAML::ELF_PF(0));
767 IO.mapOptional(
"Sections", Phdr.
Sections);
768 IO.mapOptional(
"VAddr", Phdr.
VAddr, Hex64(0));
769 IO.mapOptional(
"PAddr", Phdr.
PAddr, Hex64(0));
770 IO.mapOptional(
"Align", Phdr.
Align);
775 struct NormalizedOther {
776 NormalizedOther(IO &)
778 NormalizedOther(IO &, uint8_t Original)
791 IO.mapOptional(
"Type", Symbol.
Type, ELFYAML::ELF_STT(0));
793 IO.mapOptional(
"Index", Symbol.
Index);
794 IO.mapOptional(
"Value", Symbol.
Value, Hex64(0));
795 IO.mapOptional(
"Size", Symbol.
Size, Hex64(0));
797 MappingNormalization<NormalizedOther, uint8_t> Keys(IO, Symbol.
Other);
798 IO.mapOptional(
"Visibility", Keys->Visibility, ELFYAML::ELF_STV(0));
799 IO.mapOptional(
"Other", Keys->Other, ELFYAML::ELF_STO(0));
805 return "Index and Section cannot both be specified for Symbol";
808 return "Large indexes are not supported";
811 return "Use a section name to define which section a symbol is defined in";
818 IO.mapOptional(
"Local", Symbols.
Local);
819 IO.mapOptional(
"Global", Symbols.
Global);
820 IO.mapOptional(
"Weak", Symbols.
Weak);
825 IO.mapRequired(
"Type", Section.
Type);
826 IO.mapOptional(
"Flags", Section.
Flags, ELFYAML::ELF_SHF(0));
827 IO.mapOptional(
"Address", Section.
Address, Hex64(0));
829 IO.mapOptional(
"AddressAlign", Section.
AddressAlign, Hex64(0));
830 IO.mapOptional(
"EntSize", Section.
EntSize);
836 IO.mapOptional(
"Content", Section.
Content);
842 IO.mapOptional(
"Size", Section.
Size, Hex64(0));
847 IO.mapOptional(
"Relocations", Section.
Relocations);
852 IO.mapRequired(
"Members", group.
Members);
862 IO.mapRequired(
"Section", sectionName.
Section);
867 IO.mapOptional(
"Version", Section.
Version, Hex16(0));
868 IO.mapRequired(
"ISA", Section.
ISALevel);
869 IO.mapOptional(
"ISARevision", Section.
ISARevision, Hex8(0));
872 IO.mapOptional(
"ASEs", Section.
ASEs, ELFYAML::MIPS_AFL_ASE(0));
873 IO.mapOptional(
"FpABI", Section.
FpABI,
875 IO.mapOptional(
"GPRSize", Section.
GPRSize,
877 IO.mapOptional(
"CPR1Size", Section.
CPR1Size,
879 IO.mapOptional(
"CPR2Size", Section.
CPR2Size,
881 IO.mapOptional(
"Flags1", Section.
Flags1, ELFYAML::MIPS_AFL_FLAGS1(0));
882 IO.mapOptional(
"Flags2", Section.
Flags2, Hex32(0));
886 IO &IO, std::unique_ptr<ELFYAML::Section> &
Section) {
887 ELFYAML::ELF_SHT sectionType;
889 sectionType = Section->Type;
891 IO.mapRequired(
"Type", sectionType);
893 switch (sectionType) {
896 if (!IO.outputting())
898 sectionMapping(IO, *cast<ELFYAML::RelocationSection>(Section.get()));
901 if (!IO.outputting())
906 if (!IO.outputting())
911 if (!IO.outputting())
916 if (!IO.outputting())
918 sectionMapping(IO, *cast<ELFYAML::RawContentSection>(Section.get()));
923 IO &io, std::unique_ptr<ELFYAML::Section> &
Section) {
925 if (!RawSection || RawSection->Size >= RawSection->Content.binary_size())
927 return "Section size must be greater or equal to the content size";
932 struct NormalizedMips64RelType {
933 NormalizedMips64RelType(IO &)
934 :
Type(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
935 Type2(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
936 Type3(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
938 NormalizedMips64RelType(IO &, ELFYAML::ELF_REL Original)
939 :
Type(Original & 0xFF),
Type2(Original >> 8 & 0xFF),
940 Type3(Original >> 16 & 0xFF),
SpecSym(Original >> 24 & 0xFF) {}
942 ELFYAML::ELF_REL denormalize(IO &) {
947 ELFYAML::ELF_REL Type;
958 assert(Object &&
"The IO context is not initialized");
960 IO.mapRequired(
"Offset", Rel.
Offset);
961 IO.mapOptional(
"Symbol", Rel.
Symbol);
963 if (Object->Header.Machine == ELFYAML::ELF_EM(
ELF::EM_MIPS) &&
965 MappingNormalization<NormalizedMips64RelType, ELFYAML::ELF_REL>
Key(
967 IO.mapRequired(
"Type", Key->Type);
968 IO.mapOptional(
"Type2", Key->Type2, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
969 IO.mapOptional(
"Type3", Key->Type3, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
970 IO.mapOptional(
"SpecSym", Key->SpecSym, ELFYAML::ELF_RSS(
ELF::RSS_UNDEF));
972 IO.mapRequired(
"Type", Rel.
Type);
974 IO.mapOptional(
"Addend", Rel.
Addend, (int64_t)0);
978 assert(!IO.getContext() &&
"The IO context is initialized already");
979 IO.setContext(&Object);
980 IO.mapTag(
"!ELF",
true);
981 IO.mapRequired(
"FileHeader", Object.
Header);
983 IO.mapOptional(
"Sections", Object.
Sections);
984 IO.mapOptional(
"Symbols", Object.
Symbols);
986 IO.setContext(
nullptr);
989 LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_AFL_REG)
990 LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_ABI_FP)
991 LLVM_YAML_STRONG_TYPEDEF(
uint32_t, MIPS_AFL_EXT)
992 LLVM_YAML_STRONG_TYPEDEF(
uint32_t, MIPS_AFL_ASE)
993 LLVM_YAML_STRONG_TYPEDEF(
uint32_t, MIPS_AFL_FLAGS1)
This file declares classes for handling the YAML representation of ELF.
static void bitset(IO &IO, ELFYAML::ELF_SHF &Value)
This class represents lattice values for constants.
static void enumeration(IO &IO, ELFYAML::ELF_ET &Value)
static void enumeration(IO &IO, ELFYAML::ELF_STT &Value)
static void enumeration(IO &IO, ELFYAML::ELF_STV &Value)
Optional< ELF_SHN > Index
static void enumeration(IO &IO, ELFYAML::ELF_SHN &Value)
static void bitset(IO &IO, ELFYAML::ELF_PF &Value)
llvm::yaml::Hex16 Version
llvm::yaml::Hex64 Address
ELFYAML::ELF_STV Visibility
static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value)
static void bitset(IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
LocalGlobalWeakSymbols Symbols
llvm::yaml::Hex64 AddressAlign
std::vector< Symbol > Weak
static void enumeration(IO &IO, ELFYAML::ELF_EM &Value)
static void groupSectionMapping(IO &IO, ELFYAML::Group &group)
StringRef sectionNameOrType
static void enumeration(IO &IO, ELFYAML::ELF_ELFCLASS &Value)
Optional< llvm::yaml::Hex64 > EntSize
std::vector< Symbol > Global
LocalGlobalWeakSymbols DynamicSymbols
static void enumeration(IO &IO, ELFYAML::MIPS_ISA &Value)
static void bitset(IO &IO, ELFYAML::ELF_STO &Value)
std::vector< ProgramHeader > ProgramHeaders
static void commonSectionMapping(IO &IO, ELFYAML::Section &Section)
static void enumeration(IO &IO, ELFYAML::ELF_PT &Value)
The instances of the Type class are immutable: once they are created, they are never changed...
static void enumeration(IO &IO, ELFYAML::ELF_REL &Value)
std::vector< std::unique_ptr< Section > > Sections
std::vector< Symbol > Local
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
llvm::yaml::Hex8 ISARevision
ArrayRef< uint8_t >::size_type binary_size() const
The number of bytes that are represented by this BinaryRef.
static void bitset(IO &IO, ELFYAML::ELF_EF &Value)
std::vector< SectionOrType > Members
static void enumeration(IO &IO, ELFYAML::ELF_ELFOSABI &Value)
static void bitset(IO &IO, ELFYAML::MIPS_AFL_ASE &Value)
static void enumeration(IO &IO, ELFYAML::MIPS_AFL_EXT &Value)
static void enumeration(IO &IO, ELFYAML::MIPS_ABI_FP &Value)
MIPS_AFL_EXT ISAExtension
static void enumeration(IO &IO, ELFYAML::ELF_ELFDATA &Value)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
static void sectionMapping(IO &IO, ELFYAML::RawContentSection &Section)
StringRef - Represent a constant reference to a string, i.e.
static void enumeration(IO &IO, ELFYAML::MIPS_AFL_REG &Value)
Optional< StringRef > Symbol
std::vector< Relocation > Relocations