diff options
author | George Rimar <grimar@accesssoftek.com> | 2019-02-26 14:14:49 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2019-02-26 14:14:49 +0000 |
commit | b75bf8784eb83cf92e6670aba614c3968972960f (patch) | |
tree | 4eb3469a4813b778084a07c5e32dcd507b78c9f2 /llvm/lib/ObjectYAML/ELFYAML.cpp | |
parent | 40ad3d2aa4b037587c3aba1aee87626830838564 (diff) | |
download | llvm-b75bf8784eb83cf92e6670aba614c3968972960f.zip llvm-b75bf8784eb83cf92e6670aba614c3968972960f.tar.gz llvm-b75bf8784eb83cf92e6670aba614c3968972960f.tar.bz2 |
[yaml2obj][obj2yaml] - Add support for the architecture specific dynamic tags.
This allows tools to parse/dump the architecture specific tags
like DT_MIPS_*, DT_PPC64_* and DT_HEXAGON_*
Also fixes a bug in DynamicTags.def which was revealed in this patch.
Differential revision: https://reviews.llvm.org/D58667
llvm-svn: 354876
Diffstat (limited to 'llvm/lib/ObjectYAML/ELFYAML.cpp')
-rw-r--r-- | llvm/lib/ObjectYAML/ELFYAML.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index b2b69d5..352048b 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -662,19 +662,44 @@ void ScalarEnumerationTraits<ELFYAML::ELF_REL>::enumeration( void ScalarEnumerationTraits<ELFYAML::ELF_DYNTAG>::enumeration( IO &IO, ELFYAML::ELF_DYNTAG &Value) { - assert(IO.getContext() && "The IO context is not initialized"); + 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. +// Disable architecture specific tags by default. We might enable them below. #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. +// 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); + switch (Object->Header.Machine) { + case ELF::EM_MIPS: +#undef MIPS_DYNAMIC_TAG +#define MIPS_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value) +#include "llvm/BinaryFormat/DynamicTags.def" +#undef MIPS_DYNAMIC_TAG +#define MIPS_DYNAMIC_TAG(name, value) + break; + case ELF::EM_HEXAGON: +#undef HEXAGON_DYNAMIC_TAG +#define HEXAGON_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value) #include "llvm/BinaryFormat/DynamicTags.def" +#undef HEXAGON_DYNAMIC_TAG +#define HEXAGON_DYNAMIC_TAG(name, value) + break; + case ELF::EM_PPC64: +#undef PPC64_DYNAMIC_TAG +#define PPC64_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value) +#include "llvm/BinaryFormat/DynamicTags.def" +#undef PPC64_DYNAMIC_TAG +#define PPC64_DYNAMIC_TAG(name, value) + break; + default: +#include "llvm/BinaryFormat/DynamicTags.def" + break; + } #undef MIPS_DYNAMIC_TAG #undef HEXAGON_DYNAMIC_TAG |