[PATCH] D137095: [readobj] Output valid JSON for GroupSections
Paul Kirth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 31 10:57:16 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 current implementation failed to output valid JSON. This patch
provides a separate implementation for the JSONELFDumper class that avoids the
incorrect formatting. Future patches can address code duplication between
LLVMELFDumper and JSONELFDumper.
Depends on D137094 <https://reviews.llvm.org/D137094>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137095
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
@@ -733,6 +733,8 @@
void printRelocations() override;
+ void printGroupSections() override;
+
private:
std::unique_ptr<DictScope> FileScope;
};
@@ -7627,3 +7629,31 @@
this->printRelocationsHelper(Sec);
}
}
+template <class ELFT> void JSONELFDumper<ELFT>::printGroupSections() {
+ ScopedPrinter &W = this->W;
+ DictScope Lists(W, "Groups");
+ std::vector<GroupSection> V = this->getGroups();
+ DenseMap<uint64_t, const GroupSection *> Map = mapSectionsToGroups(V);
+ for (const GroupSection &G : V) {
+ DictScope D(W, "Group");
+ W.printNumber("Name", G.Name, G.ShName);
+ W.printNumber("Index", G.Index);
+ W.printNumber("Link", G.Link);
+ W.printNumber("Info", G.Info);
+ W.printHex("Type", getGroupType(G.Type), G.Type);
+ W.startLine() << "Signature: " << G.Signature << "\n";
+
+ ListScope L(W, "GroupSections");
+ for (const GroupMember &GM : G.Members) {
+ const GroupSection *MainGroup = Map[GM.Index];
+ if (MainGroup != &G)
+ this->reportUniqueWarning(
+ "section with index " + Twine(GM.Index) +
+ ", included in the group section with index " +
+ Twine(MainGroup->Index) +
+ ", was also found in the group section with index " +
+ Twine(G.Index));
+ W.printNumber("GroupMember", GM.Index);
+ }
+ }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137095.472074.patch
Type: text/x-patch
Size: 1544 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221031/d11f090e/attachment.bin>
More information about the llvm-commits
mailing list