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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 14:59:17 PDT 2024


================
@@ -7365,6 +7369,55 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printDynamicTable() {
   W.startLine() << "]\n";
 }
 
+template <class ELFT>
+void JSONELFDumper<ELFT>::printAuxillaryDynamicTableEntryInfo(
+    const Elf_Dyn &Entry) {
+  switch (Entry.getTag()) {
+  case DT_SONAME:
+    this->W.printString("Name", this->getDynamicString(Entry.getVal()));
+    break;
+  case DT_AUXILIARY:
+    LLVM_FALLTHROUGH;
+  case DT_FILTER:
+    LLVM_FALLTHROUGH;
+  case DT_NEEDED: {
+    ListScope L(this->W, "Libraries");
+    this->W.printString(this->getDynamicString(Entry.getVal()));
+  } break;
+  case DT_USED: {
+    ListScope L(this->W, "Objects");
+    this->W.printString(this->getDynamicString(Entry.getVal()));
+  } break;
+  case DT_RPATH:
+    LLVM_FALLTHROUGH;
+  case DT_RUNPATH: {
+    ListScope L(this->W, "Path");
+    this->W.printString(this->getDynamicString(Entry.getVal()));
+  } break;
+  case DT_FLAGS:
+    LLVM_FALLTHROUGH;
+  case DT_FLAGS_1:
+    this->W.printString("Flags",
+                        this->getDynamicEntry(Entry.getTag(), Entry.getVal()));
+    break;
+  default:
+    break;
----------------
MaskRay wrote:

Perhaps `return` for the default clause.

Add a `this->W.printString(this->getDynamicString(Entry.getVal()));` after the switch table for these string tags.

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


More information about the llvm-commits mailing list