[PATCH] D137094: [readobj] Emit valid JSON when emitting Relocations
Paul Kirth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 31 10:52:44 PDT 2022
paulkirth created this revision.
Herald added a reviewer: jhenderson.
Herald added a project: All.
paulkirth requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
The shared LLVM implementation did not emit valid JSON. This provides a separate
`printRelocations()` implementation for the JSONELFDumper.
Depends on D137092 <https://reviews.llvm.org/D137092>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137094
Files:
llvm/tools/llvm-readobj/ELFDumper.cpp
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -731,6 +731,8 @@
void printRelRelaReloc(const Relocation<ELFT> &R,
const RelSymbol<ELFT> &RelSym) override;
+ void printRelocations() override;
+
private:
std::unique_ptr<DictScope> FileScope;
};
@@ -7610,3 +7612,18 @@
}
return SymOtherFlags;
}
+
+template <class ELFT> void JSONELFDumper<ELFT>::printRelocations() {
+ ListScope D(this->W, "Relocations");
+
+ for (const Elf_Shdr &Sec : cantFail(this->Obj.sections())) {
+ if (!isRelocationSec<ELFT>(Sec))
+ continue;
+
+ StringRef Name = this->getPrintableSectionName(Sec);
+ unsigned SecNdx = &Sec - &cantFail(this->Obj.sections()).front();
+ DictScope Group(this->W);
+ this->W.printNumber("SectionIdx", SecNdx);
+ this->printRelocationsHelper(Sec);
+ }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137094.472072.patch
Type: text/x-patch
Size: 980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221031/1459e599/attachment.bin>
More information about the llvm-commits
mailing list