diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -222,8 +222,24 @@ static bool QuietDisasm = false; +// Enumeration of function kinds, and their mapping to function kind values +// from call graph section (.callgraph). +// Must stay in sync with enum from llvm/include/llvm/CodeGen/AsmPrinter.h. +enum FunctionKind { + // Function cannot be target to indirect calls. + NOT_INDIRECT_TARGET = 0, + // Function may be target to indirect calls but its type id is unknown. + INDIRECT_TARGET_UNKNOWN_TID = 1, + // Function may be target to indirect calls and its type id is known. + INDIRECT_TARGET_KNOWN_TID = 2, + + // Available in the binary but not listed in the call graph section. + NOT_LISTED = -1, +}; + struct FunctionInfo { std::string Name; + FunctionKind Kind; struct DirectCallSite { uint64_t CallSite; @@ -1388,6 +1404,8 @@ auto FuncPc = Symbols[SI].Addr; auto FuncName = Symbols[SI].Name.str(); FuncInfo[FuncPc].Name = FuncName; + // Initalize to be later updated while parsing the call graph section. + FuncInfo[FuncPc].Kind = NOT_LISTED; } while (Index < End) { // ARM and AArch64 ELF binaries can interleave data and text in the