mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 23:23:38 -04:00
[yaml2obj][obj2yaml] - Add support for dumping/parsing .dynamic sections.
This teaches the tools to parse and dump the .dynamic section and its dynamic tags. Differential revision: https://reviews.llvm.org/D57691 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353606 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user