[llvm] [llvm-readobj][ELF] Fix broken JSON output with --dynamic-table (PR #95976)

Fred Grim via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 19 10:04:06 PDT 2024


================
@@ -7365,6 +7367,19 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printDynamicTable() {
   W.startLine() << "]\n";
 }
 
+template <class ELFT> void JSONELFDumper<ELFT>::printDynamicTable() {
+  Elf_Dyn_Range Table = this->dynamic_table();
+  ListScope L(this->W, "DynamicSection");
+  for (const auto &Entry : Table) {
+    DictScope D(this->W);
+    uintX_t Tag = Entry.getTag();
+    std::string Value = this->getDynamicEntry(Tag, Entry.getVal());
+    this->W.printHex("Tag", Tag);
+    this->W.printString("Value", Value);
+    this->W.printString("Type", this->Obj.getDynamicTagAsString(Tag));
----------------
feg208 wrote:

1. I do like having the type string there but I can appreciate that it's duplicative.
2. Yeah. what about a construct like
```
"Value": { "bytes": 16 },
"Type": "PLTRELSZ",
},
....
"Value": { "Shared library": "[D]" }
"Type": "NEEDED"
},
...
"Value": {"value": 4096 },
"Type": "HASH"
},
```

and so on?



https://github.com/llvm/llvm-project/pull/95976


More information about the llvm-commits mailing list