[llvm] [llvm-readobj] Print all callgraph sections (PR #198929)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 2 01:06:58 PDT 2026


================
@@ -8338,101 +8338,108 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
     return;
   }
 
-  // Process and print the first SHT_LLVM_CALL_GRAPH type section found.
-  if (!this->processCallGraphSection(MapOrErr->begin()->first) ||
-      this->FuncCGInfos.empty())
-    return;
+  std::unique_ptr<ListScope> CGI;
+  SmallVector<FunctionCallgraphInfo, 16> FuncCGInfos;
+  for (const auto &CGMapEntry : *MapOrErr) {
+    const Elf_Shdr *CGSection = CGMapEntry.first;
+    const Elf_Shdr *CGRelSection = CGMapEntry.second;
 
-  std::vector<Relocation<ELFT>> Relocations;
-  const Elf_Shdr *RelocSymTab = nullptr;
-  if (this->Obj.getHeader().e_type == ELF::ET_REL) {
-    const Elf_Shdr *CGRelSection = MapOrErr->front().second;
-    if (CGRelSection) {
-      Expected<const typename ELFT::Shdr *> SymtabOrErr =
-          this->Obj.getSection(CGRelSection->sh_link);
-      if (!SymtabOrErr) {
-        reportWarning(createError("invalid section linked to " +
-                                  this->describe(*CGRelSection) + ": " +
-                                  toString(SymtabOrErr.takeError())),
-                      this->FileName);
-        return;
+    FuncCGInfos.clear();
+    if (!this->processCallGraphSection(CGSection, FuncCGInfos) ||
----------------
jh7370 wrote:

How about changing `processCallGraphSection` to return the `FuncCGInfos` instead? That would remove the need for a parameter to be passed in purely for output purposes and simplify this if (you'd just check the `FuncCGInfos.empty()` call in the if, after calling the function.

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


More information about the llvm-commits mailing list