[llvm] [llvm-readobj] Dump callgraph section info for ELF (PR #157499)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 19 02:27:34 PST 2025
================
@@ -5263,6 +5297,185 @@ template <class ELFT> void GNUELFDumper<ELFT>::printCGProfile() {
OS << "GNUStyle::printCGProfile not implemented\n";
}
+template <class ELFT>
+static std::optional<object::SectionRef>
+getCallGraphSection(const object::ELFObjectFile<ELFT> &ObjF) {
+ // Get the .llvm.callgraph section.
+ StringRef CallGraphSectionName(".llvm.callgraph");
+ for (auto Sec : ObjF.sections()) {
+ if (Expected<StringRef> NameOrErr = Sec.getName()) {
+ StringRef Name = *NameOrErr;
+ if (Name == CallGraphSectionName)
+ return Sec;
+ } else
+ consumeError(NameOrErr.takeError());
----------------
jh7370 wrote:
`consumeError` is generally a code smell.
Can an actual error be emitted here? If so, it should either be propagated or reported as a warning. If it can't ever fail here, `cantFail` is more appropriate.
https://github.com/llvm/llvm-project/pull/157499
More information about the llvm-commits
mailing list