diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -733,6 +733,8 @@ void printRelocations() override; + void printGroupSections() override; + private: std::unique_ptr FileScope; }; @@ -7627,3 +7629,31 @@ this->printRelocationsHelper(Sec); } } +template void JSONELFDumper::printGroupSections() { + ScopedPrinter &W = this->W; + DictScope Lists(W, "Groups"); + std::vector V = this->getGroups(); + DenseMap 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); + } + } +}