summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ObjectYAML/ELFYAML.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-02-09 11:34:28 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-02-09 11:34:28 +0000
commit0e7ed91264c6502389f6ec0d36d9857c2d64b6d1 (patch)
tree276a0fea5ea0a186473ef8f8ba34240426a29676 /llvm/lib/ObjectYAML/ELFYAML.cpp
parent283d103bde5bfdd59d9836e0c72ca7258df6cdd7 (diff)
downloadbcm5719-llvm-0e7ed91264c6502389f6ec0d36d9857c2d64b6d1.tar.gz
bcm5719-llvm-0e7ed91264c6502389f6ec0d36d9857c2d64b6d1.zip
[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 llvm-svn: 353606
Diffstat (limited to 'llvm/lib/ObjectYAML/ELFYAML.cpp')
-rw-r--r--llvm/lib/ObjectYAML/ELFYAML.cpp46
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());
OpenPOWER on IntegriCloud