[llvm] [llvm-objdump] Handle .callgraph section (PR #151009)
Prabhu Rajasekaran via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 28 11:15:30 PDT 2025
================
@@ -3131,6 +3225,207 @@ void Dumper::printSymbol(const SymbolRef &Symbol,
outs() << ' ' << SymName << '\n';
}
+static void printCallGraphInfo(ObjectFile *Obj) {
+ // Get function info through disassembly.
+ disassembleObject(Obj, /*InlineRelocs=*/false, outs());
+
+ // Get the .callgraph section.
+ StringRef CallGraphSectionName(".callgraph");
+ std::optional<object::SectionRef> CallGraphSection;
+ for (auto Sec : ToolSectionFilter(*Obj)) {
+ StringRef Name;
+ if (Expected<StringRef> NameOrErr = Sec.getName())
+ Name = *NameOrErr;
+ else
+ consumeError(NameOrErr.takeError());
+
+ if (Name == CallGraphSectionName) {
+ CallGraphSection = Sec;
+ break;
+ }
+ }
+ if (!CallGraphSection)
+ reportWarning("there is no .callgraph section", Obj->getFileName());
+
+ // Map type id to indirect call sites.
+ MapVector<uint64_t, SmallVector<uint64_t>> TypeIdToIndirCallSites;
+ // Map type id to indirect targets.
+ MapVector<uint64_t, SmallVector<uint64_t>> TypeIdToIndirTargets;
+ // Instructions that are not indirect calls but have a type id are ignored.
+ uint64_t IgnoredICallIdCount = 0;
+ // Number of valid indirect calls with type ids.
+ uint64_t ICallWithTypeIdCount = 0;
+ if (CallGraphSection) {
----------------
Prabhuk wrote:
Should we handle direct callsites and print them out even if the CallgraphSection is empty?
https://github.com/llvm/llvm-project/pull/151009
More information about the llvm-commits
mailing list