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

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 22 14:09:26 PDT 2025


================
@@ -5357,197 +5357,232 @@ template <class ELFT> bool ELFDumper<ELFT>::processCallGraphSection() {
   DataExtractor Data(SectionBytesOrErr.get(), Obj.isLE(),
                      ObjF.getBytesInAddress());
 
-  uint64_t NotListedCount = 0;
   uint64_t UnknownCount = 0;
-
   uint64_t Offset = 0;
   while (Offset < CGSection->sh_size) {
     Error CGSectionErr = Error::success();
-    // Format version number.
-    uint64_t FormatVersionNumber = Data.getU64(&Offset, &CGSectionErr);
-
+    uint8_t FormatVersionNumber = Data.getU8(&Offset, &CGSectionErr);
     if (CGSectionErr)
       reportError(std::move(CGSectionErr),
                   "While reading call graph info FormatVersionNumber");
 
     if (FormatVersionNumber != 0) {
       Error FormatErr = createError("Unknown format version value [" +
                                     std::to_string(FormatVersionNumber) +
-                                    "] in .callgraph section.");
+                                    "] in .llvm.callgraph section.");
       reportError(std::move(FormatErr), "Unknown value");
     }
 
-    // Read function address.
+    uint8_t Flags = Data.getU8(&Offset, &CGSectionErr);
+    if (CGSectionErr)
+      reportError(std::move(CGSectionErr),
+                  "While reading call graph info's Flags");
+    switch (Flags) {
+    case 1:
+    case 3:
+    case 5:
+    case 7:
----------------
ilovepi wrote:

Not really sure what's going on here. I'd have expected these to be enum values, or some other standard constants. Where do these specific flags come from?

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


More information about the llvm-commits mailing list