diff options
Diffstat (limited to 'llvm/lib/ObjectYAML/ELFYAML.cpp')
-rw-r--r-- | llvm/lib/ObjectYAML/ELFYAML.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index a89180dc82d..4707a44fbd3 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -661,6 +661,33 @@ void ScalarEnumerationTraits<ELFYAML::ELF_REL>::enumeration( IO.enumFallback<Hex32>(Value); } +void ScalarEnumerationTraits<ELFYAML::ELF_DYNTAG>::enumeration( + IO &IO, ELFYAML::ELF_DYNTAG &Value) { + const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext()); + assert(Object && "The IO context is not initialized"); + +// TODO: For simplicity we do not handle target specific flags. They are +// still supported and will be shown as a raw numeric values in the output. +#define MIPS_DYNAMIC_TAG(name, value) +#define HEXAGON_DYNAMIC_TAG(name, value) +#define PPC64_DYNAMIC_TAG(name, value) +// Also ignore marker tags such as DT_HIOS (maps to DT_VERNEEDNUM), etc. +#define DYNAMIC_TAG_MARKER(name, value) + +#define STRINGIFY(X) (#X) +#define DYNAMIC_TAG(X, Y) IO.enumCase(Value, STRINGIFY(DT_##X), ELF::DT_##X); +#include "llvm/BinaryFormat/DynamicTags.def" + +#undef MIPS_DYNAMIC_TAG +#undef HEXAGON_DYNAMIC_TAG +#undef PPC64_DYNAMIC_TAG +#undef DYNAMIC_TAG_MARKER +#undef STRINGIFY +#undef DYNAMIC_TAG + + IO.enumFallback<Hex64>(Value); +} + void ScalarEnumerationTraits<ELFYAML::MIPS_AFL_REG>::enumeration( IO &IO, ELFYAML::MIPS_AFL_REG &Value) { #define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X) @@ -831,6 +858,11 @@ static void commonSectionMapping(IO &IO, ELFYAML::Section &Section) { IO.mapOptional("Info", Section.Info, StringRef()); } +static void sectionMapping(IO &IO, ELFYAML::DynamicSection &Section) { + commonSectionMapping(IO, Section); + IO.mapOptional("Entries", Section.Entries); +} + static void sectionMapping(IO &IO, ELFYAML::RawContentSection &Section) { commonSectionMapping(IO, Section); IO.mapOptional("Content", Section.Content); @@ -891,6 +923,11 @@ void MappingTraits<std::unique_ptr<ELFYAML::Section>>::mapping( IO.mapRequired("Type", sectionType); switch (sectionType) { + case ELF::SHT_DYNAMIC: + if (!IO.outputting()) + Section.reset(new ELFYAML::DynamicSection()); + sectionMapping(IO, *cast<ELFYAML::DynamicSection>(Section.get())); + break; case ELF::SHT_REL: case ELF::SHT_RELA: if (!IO.outputting()) @@ -952,6 +989,15 @@ struct NormalizedMips64RelType { } // end anonymous namespace +void MappingTraits<ELFYAML::DynamicEntry>::mapping(IO &IO, + ELFYAML::DynamicEntry &Rel) { + const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext()); + assert(Object && "The IO context is not initialized"); + + IO.mapRequired("Tag", Rel.Tag); + IO.mapRequired("Value", Rel.Val); +} + void MappingTraits<ELFYAML::Relocation>::mapping(IO &IO, ELFYAML::Relocation &Rel) { const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext()); |