[llvm] [llvm-readobj] Dump callgraph section info for ELF (PR #157499)

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 21 10:45:33 PST 2025


================
@@ -432,9 +445,31 @@ template <typename ELFT> class ELFDumper : public ObjDumper {
       const SFrameParser<ELFT::Endianness> &Parser,
       const typename SFrameParser<ELFT::Endianness>::FDERange::iterator FDE,
       ArrayRef<Relocation<ELFT>> Relocations, const Elf_Shdr *RelocSymTab);
+  // Callgraph - Main data structure to maintain per function callgraph
+  // information.
+  SmallVector<FunctionCallgraphInfo, 16> FuncCGInfos;
+
+  // Read the .llvm.callgraph section and process its contents to populate
+  // call graph related data structures which will be used to dump call graph
+  // info. Returns false if there is no .llvm.callgraph section in the input
+  // file.
+  bool processCallGraphSection();
+
+  void getCallGraphRelocations(std::vector<Relocation<ELFT>> &Relocations,
+                               const Elf_Shdr *&RelocSymTab);
 
 private:
   mutable SmallVector<std::optional<VersionEntry>, 0> VersionMap;
+
+protected:
+  SmallVector<std::string> getFunctionNames(uint64_t FuncAddr) {
+    SmallVector<uint32_t> FuncSymIndexes =
+        this->getSymbolIndexesForFunctionAddress(FuncAddr, std::nullopt);
+    SmallVector<std::string> FuncSymNames;
----------------
ilovepi wrote:

you know the size at this point, so you can use `reserve()` to avoid extra allocations + copies on push_back when the vector grows.

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


More information about the llvm-commits mailing list