[llvm] Reland "[llvm-readobj] Dump callgraph section info for ELF" (PR #176260)

Prabhu Rajasekaran via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 13 12:12:40 PST 2026


https://github.com/Prabhuk updated https://github.com/llvm/llvm-project/pull/176260

>From 346e181f3df6c67952ec58f00e4bf7a922129cee Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Thu, 15 Jan 2026 22:26:07 +0000
Subject: [PATCH 01/22] Reland "[llvm-readobj] Dump callgraph section info for
 ELF"

This patch is a reland of #157499

Introduce a new flag --call-graph-info which outputs call graph
information in the ELF call graph section in JSON or LLVM style.
---
 llvm/docs/CommandGuide/llvm-readelf.rst       |  16 +-
 llvm/docs/CommandGuide/llvm-readobj.rst       |  42 +-
 .../ELF/call-graph-info-warn-malformed.test   | 382 +++++++++++++
 .../llvm-readobj/ELF/call-graph-info.test     | 527 ++++++++++++++++++
 llvm/tools/llvm-readobj/ELFDumper.cpp         | 278 ++++++++-
 llvm/tools/llvm-readobj/ObjDumper.h           |   1 +
 llvm/tools/llvm-readobj/Opts.td               |   1 +
 llvm/tools/llvm-readobj/llvm-readobj.cpp      |   4 +
 8 files changed, 1229 insertions(+), 22 deletions(-)
 create mode 100644 llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
 create mode 100644 llvm/test/tools/llvm-readobj/ELF/call-graph-info.test

diff --git a/llvm/docs/CommandGuide/llvm-readelf.rst b/llvm/docs/CommandGuide/llvm-readelf.rst
index 5403fea60d5ee..ed349d1d15761 100644
--- a/llvm/docs/CommandGuide/llvm-readelf.rst
+++ b/llvm/docs/CommandGuide/llvm-readelf.rst
@@ -38,6 +38,18 @@ OPTIONS
  Display the contents of the basic block address map section(s), which contain the
  address of each function, along with the relative offset of each basic block.
 
+.. option:: --call-graph-info
+
+  Display the call graph section entries i.e. for each function
+  its identifying information, each of its direct callees' information
+  and for each indirect callee a 64 bit number representing the callee's
+  function signature. This information can be used to reconstruct
+  the program call graph.
+
+.. option:: --cg-profile
+
+ Display the callgraph profile section.
+
 .. option:: --decompress, -z
 
   Dump decompressed section content when used with ``-x`` or ``-p``.
@@ -63,10 +75,6 @@ OPTIONS
 
  Display the dynamic table.
 
-.. option:: --cg-profile
-
- Display the callgraph profile section.
-
 .. option:: --histogram, -I
 
  Display a bucket list histogram for dynamic symbol hash tables.
diff --git a/llvm/docs/CommandGuide/llvm-readobj.rst b/llvm/docs/CommandGuide/llvm-readobj.rst
index 0d05b947a6b3e..5498f9574ad13 100644
--- a/llvm/docs/CommandGuide/llvm-readobj.rst
+++ b/llvm/docs/CommandGuide/llvm-readobj.rst
@@ -181,13 +181,17 @@ The following options are implemented only for the ELF file format.
  When pgo analysis maps are present, all analyses are printed as their raw
  value.
 
-.. option:: --pretty-pgo-analysis-map
+.. option:: --call-graph-info
 
- When pgo analysis maps are present in the basic block address map section(s),
- analyses with special formats (i.e. BlockFrequency, BranchProbability, etc)
- are printed using the same format as their respective analysis pass.
+  Display the call graph section entries i.e. for each function
+  its identifying information, each of its direct callees' information
+  and for each indirect callee a 64 bit number representing the callee's
+  function signature. This information can be used to reconstruct
+  the program call graph.
 
- Requires :option:`--bb-addr-map` to have an effect.
+.. option:: --cg-profile
+
+ Display the callgraph profile section.
 
 .. option:: --dependent-libraries
 
@@ -205,14 +209,6 @@ The following options are implemented only for the ELF file format.
 
  Display the dynamic table.
 
-.. option:: --cg-profile
-
- Display the callgraph profile section.
-
-.. option:: --histogram, -I
-
- Display a bucket list histogram for dynamic symbol hash tables.
-
 .. option:: --elf-linker-options
 
  Display the linker options section.
@@ -224,10 +220,6 @@ The following options are implemented only for the ELF file format.
  structured format. ``GNU`` output mimics the equivalent GNU :program:`readelf`
  output. ``JSON`` is JSON formatted output intended for machine consumption.
 
-.. option:: --section-groups, -g
-
- Display section groups.
-
 .. option:: --gnu-hash-table
 
  Display the GNU hash table for dynamic symbols.
@@ -240,6 +232,10 @@ The following options are implemented only for the ELF file format.
 
  Display the hash table for dynamic symbols.
 
+.. option:: --histogram, -I
+
+ Display a bucket list histogram for dynamic symbol hash tables.
+
 .. option:: --memtag
 
  Display information about memory tagging present in the binary. This includes
@@ -250,6 +246,14 @@ The following options are implemented only for the ELF file format.
 
  Display all notes.
 
+.. option:: --pretty-pgo-analysis-map
+
+ When pgo analysis maps are present in the basic block address map section(s),
+ analyses with special formats (i.e. BlockFrequency, BranchProbability, etc)
+ are printed using the same format as their respective analysis pass.
+
+ Requires :option:`--bb-addr-map` to have an effect.
+
 .. option:: --pretty-print
 
  When used with :option:`--elf-output-style`, JSON output will be formatted in
@@ -259,6 +263,10 @@ The following options are implemented only for the ELF file format.
 
  Display the program headers.
 
+.. option:: --section-groups, -g
+
+ Display section groups.
+
 .. option:: --section-mapping
 
  Display the section to segment mapping.
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
new file mode 100644
index 0000000000000..e1396cabb8784
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -0,0 +1,382 @@
+## Tests that --call-graph-info produces useful warnings
+## if SHT_LLVM_CALL_GRAPH type section processing idenitifies
+## malformed content.
+
+## Tests that --call-graph-info warns if there is no section of type SHT_LLVM_CALL_GRAPH.
+# RUN: yaml2obj --docnum=1 %s -o %t1
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t1 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t1 --check-prefix=WARN_NO_SECTION
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t1 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t1 --check-prefix=WARN_NO_SECTION
+
+# WARN_NO_SECTION: warning: '[[FILE]]': no SHT_LLVM_CALL_GRAPH section found
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_DYN
+  Machine:  EM_X86_64
+...
+
+## Check format version number.
+# RUN: yaml2obj --docnum=2 %s -o %t2
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t2 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t2 --check-prefix=WARN_FMT_VERSION
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t2 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t2 --check-prefix=WARN_FMT_VERSION
+
+# WARN_FMT_VERSION: warning: '[[FILE]]': unknown format version value [1] in SHT_LLVM_CALL_GRAPH type section
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_DYN
+  Machine:  EM_X86_64
+Sections:
+  - Name:  .text
+    Type:  SHT_PROGBITS
+    Size:  5
+  - Name:  .llvm.callgraph
+    Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [
+      # --- Entry 1: foo (foo) ---
+      0x01, # Format Version - only supported value is 0x00
+    ]
+Symbols:
+  - Name:  foo
+...
+
+## Check missing flags.
+# RUN: yaml2obj --docnum=3 %s -o %t3
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t3 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t3 --check-prefix=WARN_MISSING_FLAG
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t3 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t3 --check-prefix=WARN_MISSING_FLAG
+
+# WARN_MISSING_FLAG: warning: '[[FILE]]': failed while reading call graph info's Flags unexpected end of data at offset 0x1 while reading [0x1, 0x2)
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_DYN
+  Machine:  EM_X86_64
+Sections:
+  - Name:  .text
+    Type:  SHT_PROGBITS
+    Size:  5
+  - Name:  .llvm.callgraph
+    Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [
+      # --- Entry 1: foo (foo) ---
+      0x00, # Format Version
+      #< Missing flags
+    ]
+Symbols:
+  - Name:  foo
+...
+
+## Check Flags.
+# RUN: yaml2obj --docnum=4 %s -o %t4
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t4 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t4 --check-prefix=WARN_FLAG
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t4 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t4 --check-prefix=WARN_FLAG
+
+# WARN_FLAG: warning: '[[FILE]]': unexpected Flags value [8]
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_DYN
+  Machine:  EM_X86_64
+Sections:
+  - Name:  .text
+    Type:  SHT_PROGBITS
+    Size:  5
+  - Name:  .llvm.callgraph
+    Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [
+      # --- Entry 1: foo (foo) ---
+      0x00, # Format Version
+      0x08, # Flags - only valid values are 0x00 to 0x07
+    ]
+Symbols:
+  - Name:  foo
+...
+
+## Check missing function entry PC.
+# RUN: yaml2obj --docnum=5 %s -o %t5
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t5 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t5 --check-prefix=WARN_MISSING_PC
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t5 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t5 --check-prefix=WARN_MISSING_PC
+
+# WARN_MISSING_PC: warning: '[[FILE]]': failed while reading call graph info function entry PC unexpected end of data at offset 0x2 while reading [0x2, 0xa)
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_DYN
+  Machine:  EM_X86_64
+Sections:
+  - Name:  .text
+    Type:  SHT_PROGBITS
+    Size:  5
+  - Name:  .llvm.callgraph
+    Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [
+      # --- Entry 1: foo (foo) ---
+      0x00, # Format Version
+      0x00, # Flags
+      #< Missing function entry PC
+    ]
+Symbols:
+  - Name:  foo
+...
+
+## Check missing function Type ID.
+# RUN: yaml2obj --docnum=6 %s -o %t6
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t6 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN_MISSING_TYPEID
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t6 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN_MISSING_TYPEID
+
+# WARN_MISSING_TYPEID: warning: '[[FILE]]': failed while reading function type ID unexpected end of data at offset 0xa while reading [0xa, 0x12)
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_DYN
+  Machine:  EM_X86_64
+Sections:
+  - Name:  .text
+    Type:  SHT_PROGBITS
+    Size:  5
+  - Name:  .llvm.callgraph
+    Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [
+      # --- Entry 1: foo (foo) ---
+      0x00, # Format Version
+      0x00, # Flags
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Function entry address
+      #< Missing Type ID
+    ]
+Symbols:
+  - Name:  foo
+...
+
+## Check missing number of direct callees.
+# RUN: yaml2obj --docnum=7 %s -o %t7
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t7 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN_MISSING_DIRECT
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t7 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN_MISSING_DIRECT
+
+# WARN_MISSING_DIRECT: warning: '[[FILE]]': failed while reading number of direct callees unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_DYN
+  Machine:  EM_X86_64
+Sections:
+  - Name:  .text
+    Type:  SHT_PROGBITS
+    Size:  5
+  - Name:  .llvm.callgraph
+    Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [
+      # --- Entry 1: foo (foo) ---
+      0x00, # Format Version
+      0x02, # Flags (HasDirectCallees)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Function entry address
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # TypeID unknown
+      #< Missing NumDirectCallees (ULEB128)
+    ]
+Symbols:
+  - Name:  foo
+...
+
+## Check missing direct callee.
+# RUN: yaml2obj --docnum=8 %s -o %t8
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t8 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN_MISSING_CALLEE
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t8 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN_MISSING_CALLEE
+
+# WARN_MISSING_CALLEE: warning: '[[FILE]]': failed while reading direct callee unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_DYN
+  Machine:  EM_X86_64
+Sections:
+  - Name:  .text
+    Type:  SHT_PROGBITS
+    Size:  5
+  - Name:  .llvm.callgraph
+    Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [
+      # --- Entry 1: foo (foo) ---
+      0x00, # Format Version
+      0x02, # Flags (HasDirectCallees)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Function entry address
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # TypeID unknown
+      0x01, # NumDirectCallees
+      #< Missing direct callee address
+    ]
+Symbols:
+  - Name:  foo
+...
+
+## Check missing number of indirect target type IDs.
+# RUN: yaml2obj --docnum=9 %s -o %t9
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t9 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t9 --check-prefix=WARN_MISSING_NUM_INDIRECT
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t9 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t9 --check-prefix=WARN_MISSING_NUM_INDIRECT
+
+# WARN_MISSING_NUM_INDIRECT: warning: '[[FILE]]': failed while reading number of indirect target type IDs unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_DYN
+  Machine:  EM_X86_64
+Sections:
+  - Name:  .text
+    Type:  SHT_PROGBITS
+    Size:  5
+  - Name:  .llvm.callgraph
+    Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [
+      # --- Entry 1: foo (foo) ---
+      0x00, # Format Version
+      0x04, # Flags (HasIndirectCallees)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Function entry address
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # TypeID unknown
+      #< Missing NumIndirectTargetTypeIDs (ULEB128)
+    ]
+Symbols:
+  - Name:  foo
+...
+
+## Check missing indirect target type ID.
+# RUN: yaml2obj --docnum=10 %s -o %t10
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t10 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t10 --check-prefix=WARN_MISSING_INDIRECT_TARGET_TYPE_ID
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t10 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t10 --check-prefix=WARN_MISSING_INDIRECT_TARGET_TYPE_ID
+
+# WARN_MISSING_INDIRECT_TARGET_TYPE_ID: warning: '[[FILE]]': failed while reading indirect target type ID unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_REL
+  Machine:  EM_X86_64
+Sections:
+  - Name:  .text
+    Type:  SHT_PROGBITS
+    Size:  5
+  - Name:  .llvm.callgraph
+    Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [
+      # --- Entry 1: foo (foo) ---
+      0x00, # Format Version
+      0x04, # Flags (HasIndirectCallees)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Function entry address
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # TypeID unknown
+      0x01, # NumIndirectTargetTypeIDs (1)
+      #< Missing indirect call entries here.
+    ]
+Symbols:
+  - Name:  foo
+...
+
+## Check missing relocation information.
+# RUN: yaml2obj --docnum=11 %s -o %t11
+# RUN: llvm-readelf --call-graph-info %t11 2>&1 | count 0
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t11 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t11 --check-prefix=WARN_NO_RELOC
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t11 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t11 --check-prefix=WARN_NO_RELOC
+
+# WARN_NO_RELOC: warning: '[[FILE]]': SHT_LLVM_CALL_GRAPH type section has unknown type id for 2 indirect targets
+# WARN_NO_RELOC: warning: '[[FILE]]': unknown relocation at offset 2
+# WARN_NO_RELOC: warning: '[[FILE]]': unknown relocation at offset 19
+# WARN_NO_RELOC: warning: '[[FILE]]': unknown relocation at offset 29
+# WARN_NO_RELOC: warning: '[[FILE]]': unknown relocation at offset 56
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_REL
+  Machine:  EM_X86_64
+Sections:
+  - Name: .text
+    Type: SHT_PROGBITS
+    Size: 12 # or whatever size is needed for all the data
+  - Name: .llvm.callgraph
+    Type: SHT_LLVM_CALL_GRAPH
+    ContentArray: [
+        '0', # Format version number
+        '3', # Flag IsIndirectTarget true, HasDirectCallees true
+        '0', '0', '0', '0', '0', '0', '0', '0', # foo()'s address
+        '0', '0', '0', '0', '0', '0', '0', '0', # foo()'s TypeID Unknown
+        '1', # NumDirectCallees
+        '0', '0', '0', '0', '0', '0', '0', '0', # Direct callee foo()'s address
+        '0', # Format version number
+        '5', # Flag IsIndirectTarget true, HasIndirectTargetTypeIDs true
+        '6', '0', '0', '0', '0', '0', '0', '0', # bar()'s address
+        '0', '0', '0', '0', '0', '0', '0', '0', # bar()'s TypeID Unknown
+        '1', # NumIndirectTargetTypeIDs
+        '16', '0', '0', '0', '0', '0', '0', '0', # Indirect callee type ID
+        '0', # Format version number
+        '1', # Flag IsIndirectTarget true
+        '10', '0', '0', '0', '0', '0', '0', '0', # baz()'s address
+        '32', '0', '0', '0', '0', '0', '0', '0', # baz()'s TypeID Unknown
+      ]
+  - Name:   .rela.llvm.callgraph
+    Type:   SHT_RELA
+    Flags:  [ SHF_INFO_LINK ]
+    Link:   .symtab
+    Relocations:
+      # 1. Pointer to foo() definition
+      - Offset: 0x2
+        Symbol: foo
+        Type:   R_X86_64_64
+
+      # 2. Pointer to the call site "callq foo" (offset 5 inside foo)
+      #    We relocate against 'foo' and add 5 to get the address of the instruction.
+      - Offset: 0x13
+        Symbol: foo
+        Type:   R_X86_64_64
+        Addend: 5
+
+      # 3. Pointer to bar() definition
+      - Offset: 0x1D
+        Symbol: bar
+        Type:   R_X86_64_64
+
+      # 4. Pointer to baz() definition
+      - Offset: 0x38
+        Symbol: baz
+        Type:   R_X86_64_64
+Symbols:
+  - Name:  foo
+  - Name:  bar
+  - Name:  baz
+...
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
new file mode 100644
index 0000000000000..79262101488a4
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
@@ -0,0 +1,527 @@
+## Tests how --call-graph-info prints the call graph information.
+
+## Check non-relocatable object file handling.
+# RUN: yaml2obj --docnum=1 %s -o %t1
+# RUN: llvm-readelf --call-graph-info %t1 2>&1 | count 0
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t1 2>&1 | \
+# RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM_NONRELOC -DFILE=%t1
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t1 2>&1 | \
+# RUN:   FileCheck %s --match-full-lines --check-prefix=JSON_NONRELOC -DFILE=%t1
+
+## We do not support GNU format console output for --call-graph-info as it is an LLVM only info.
+# GNU_NONRELOC-NOT: .
+
+# LLVM_NONRELOC:      CallGraph [
+# LLVM_NONRELOC-NEXT:     Function {
+# LLVM_NONRELOC-NEXT:       Names: [foo]
+# LLVM_NONRELOC-NEXT:       Address: 0x1790
+# LLVM_NONRELOC-NEXT:       Version: 0
+# LLVM_NONRELOC-NEXT:       IsIndirectTarget: Yes
+# LLVM_NONRELOC-NEXT:       TypeId: 0x3ECBEEF531F74424
+# LLVM_NONRELOC-NEXT:       NumDirectCallees: 0
+# LLVM_NONRELOC-NEXT:       DirectCallees [
+# LLVM_NONRELOC-NEXT:       ]
+# LLVM_NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
+# LLVM_NONRELOC-NEXT:       IndirectTypeIDs: []
+# LLVM_NONRELOC-NEXT:     }
+# LLVM_NONRELOC-NEXT:     Function {
+# LLVM_NONRELOC-NEXT:       Names: [bar]
+# LLVM_NONRELOC-NEXT:       Address: 0x17A0
+# LLVM_NONRELOC-NEXT:       Version: 0
+# LLVM_NONRELOC-NEXT:       IsIndirectTarget: Yes
+# LLVM_NONRELOC-NEXT:       TypeId: 0x3ECBEEF531F74424
+# LLVM_NONRELOC-NEXT:       NumDirectCallees: 0
+# LLVM_NONRELOC-NEXT:       DirectCallees [
+# LLVM_NONRELOC-NEXT:       ]
+# LLVM_NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
+# LLVM_NONRELOC-NEXT:       IndirectTypeIDs: []
+# LLVM_NONRELOC-NEXT:     }
+# LLVM_NONRELOC-NEXT:     Function {
+# LLVM_NONRELOC-NEXT:       Names: [baz]
+# LLVM_NONRELOC-NEXT:       Address: 0x17B0
+# LLVM_NONRELOC-NEXT:       Version: 0
+# LLVM_NONRELOC-NEXT:       IsIndirectTarget: Yes
+# LLVM_NONRELOC-NEXT:       TypeId: 0x308E4B8159BC8654
+# LLVM_NONRELOC-NEXT:       NumDirectCallees: 0
+# LLVM_NONRELOC-NEXT:       DirectCallees [
+# LLVM_NONRELOC-NEXT:       ]
+# LLVM_NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
+# LLVM_NONRELOC-NEXT:       IndirectTypeIDs: []
+# LLVM_NONRELOC-NEXT:     }
+# LLVM_NONRELOC-NEXT:     Function {
+# LLVM_NONRELOC-NEXT:       Names: [main]
+# LLVM_NONRELOC-NEXT:       Address: 0x17C0
+# LLVM_NONRELOC-NEXT:       Version: 0
+# LLVM_NONRELOC-NEXT:       IsIndirectTarget: Yes
+# LLVM_NONRELOC-NEXT:       TypeId: 0xFA6809609A76AFCA
+# LLVM_NONRELOC-NEXT:       NumDirectCallees: 3
+# LLVM_NONRELOC-NEXT:       DirectCallees [
+# LLVM_NONRELOC-NEXT:         {
+# LLVM_NONRELOC-NEXT:           Names: [foo]
+# LLVM_NONRELOC-NEXT:           Address: 0x1790
+# LLVM_NONRELOC-NEXT:         }
+# LLVM_NONRELOC-NEXT:         {
+# LLVM_NONRELOC-NEXT:           Names: [bar]
+# LLVM_NONRELOC-NEXT:           Address: 0x17A0
+# LLVM_NONRELOC-NEXT:         }
+# LLVM_NONRELOC-NEXT:         {
+# LLVM_NONRELOC-NEXT:           Names: [baz]
+# LLVM_NONRELOC-NEXT:           Address: 0x17B0
+# LLVM_NONRELOC-NEXT:         }
+# LLVM_NONRELOC-NEXT:       ]
+# LLVM_NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 2
+# LLVM_NONRELOC-NEXT:       IndirectTypeIDs: [0x3ECBEEF531F74424, 0x308E4B8159BC8654]
+# LLVM_NONRELOC-NEXT:     }
+# LLVM_NONRELOC-NEXT:   ]
+
+# JSON_NONRELOC:     "CallGraph": [
+# JSON_NONRELOC-NEXT:      {
+# JSON_NONRELOC-NEXT:        "Function": {
+# JSON_NONRELOC-NEXT:          "Names": [
+# JSON_NONRELOC-NEXT:            "foo"
+# JSON_NONRELOC-NEXT:          ],
+# JSON_NONRELOC-NEXT:          "Address": 6032,
+# JSON_NONRELOC-NEXT:          "Version": 0,
+# JSON_NONRELOC-NEXT:          "IsIndirectTarget": true,
+# JSON_NONRELOC-NEXT:          "TypeId": 4524972987496481828,
+# JSON_NONRELOC-NEXT:          "NumDirectCallees": 0,
+# JSON_NONRELOC-NEXT:          "DirectCallees": [],
+# JSON_NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON_NONRELOC-NEXT:          "IndirectTypeIDs": []
+# JSON_NONRELOC-NEXT:        }
+# JSON_NONRELOC-NEXT:      },
+# JSON_NONRELOC-NEXT:      {
+# JSON_NONRELOC-NEXT:        "Function": {
+# JSON_NONRELOC-NEXT:          "Names": [
+# JSON_NONRELOC-NEXT:            "bar"
+# JSON_NONRELOC-NEXT:          ],
+# JSON_NONRELOC-NEXT:          "Address": 6048,
+# JSON_NONRELOC-NEXT:          "Version": 0,
+# JSON_NONRELOC-NEXT:          "IsIndirectTarget": true,
+# JSON_NONRELOC-NEXT:          "TypeId": 4524972987496481828,
+# JSON_NONRELOC-NEXT:          "NumDirectCallees": 0,
+# JSON_NONRELOC-NEXT:          "DirectCallees": [],
+# JSON_NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON_NONRELOC-NEXT:          "IndirectTypeIDs": []
+# JSON_NONRELOC-NEXT:        }
+# JSON_NONRELOC-NEXT:      },
+# JSON_NONRELOC-NEXT:      {
+# JSON_NONRELOC-NEXT:        "Function": {
+# JSON_NONRELOC-NEXT:          "Names": [
+# JSON_NONRELOC-NEXT:            "baz"
+# JSON_NONRELOC-NEXT:          ],
+# JSON_NONRELOC-NEXT:          "Address": 6064,
+# JSON_NONRELOC-NEXT:          "Version": 0,
+# JSON_NONRELOC-NEXT:          "IsIndirectTarget": true,
+# JSON_NONRELOC-NEXT:          "TypeId": 3498816979441845844,
+# JSON_NONRELOC-NEXT:          "NumDirectCallees": 0,
+# JSON_NONRELOC-NEXT:          "DirectCallees": [],
+# JSON_NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON_NONRELOC-NEXT:          "IndirectTypeIDs": []
+# JSON_NONRELOC-NEXT:        }
+# JSON_NONRELOC-NEXT:      },
+# JSON_NONRELOC-NEXT:      {
+# JSON_NONRELOC-NEXT:        "Function": {
+# JSON_NONRELOC-NEXT:          "Names": [
+# JSON_NONRELOC-NEXT:            "main"
+# JSON_NONRELOC-NEXT:          ],
+# JSON_NONRELOC-NEXT:          "Address": 6080,
+# JSON_NONRELOC-NEXT:          "Version": 0,
+# JSON_NONRELOC-NEXT:          "IsIndirectTarget": true,
+# JSON_NONRELOC-NEXT:          "TypeId": 18043682217572872138,
+# JSON_NONRELOC-NEXT:          "NumDirectCallees": 3,
+# JSON_NONRELOC-NEXT:          "DirectCallees": [
+# JSON_NONRELOC-NEXT:            {
+# JSON_NONRELOC-NEXT:              "Names": [
+# JSON_NONRELOC-NEXT:                "foo"
+# JSON_NONRELOC-NEXT:              ],
+# JSON_NONRELOC-NEXT:              "Address": 6032
+# JSON_NONRELOC-NEXT:            },
+# JSON_NONRELOC-NEXT:            {
+# JSON_NONRELOC-NEXT:              "Names": [
+# JSON_NONRELOC-NEXT:                "bar"
+# JSON_NONRELOC-NEXT:              ],
+# JSON_NONRELOC-NEXT:              "Address": 6048
+# JSON_NONRELOC-NEXT:            },
+# JSON_NONRELOC-NEXT:            {
+# JSON_NONRELOC-NEXT:              "Names": [
+# JSON_NONRELOC-NEXT:                "baz"
+# JSON_NONRELOC-NEXT:              ],
+# JSON_NONRELOC-NEXT:              "Address": 6064
+# JSON_NONRELOC-NEXT:            }
+# JSON_NONRELOC-NEXT:          ],
+# JSON_NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 2,
+# JSON_NONRELOC-NEXT:          "IndirectTypeIDs": [
+# JSON_NONRELOC-NEXT:            4524972987496481828,
+# JSON_NONRELOC-NEXT:            3498816979441845844
+# JSON_NONRELOC-NEXT:          ]
+# JSON_NONRELOC-NEXT:        }
+# JSON_NONRELOC-NEXT:      }
+# JSON_NONRELOC-NEXT:    ]
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_DYN
+  Machine:  EM_X86_64
+Sections:
+  - Name:   .text
+    Type:   SHT_PROGBITS
+    Flags:  [ SHF_ALLOC, SHF_EXECINSTR ]
+    Size:   0x2000
+  - Name:   .llvm.callgraph
+    Type:   SHT_LLVM_CALL_GRAPH
+    Flags:  [ SHF_LINK_ORDER ]
+    Link:   .text
+    ContentArray: [
+      # --- foo ---
+      0x00, # Version
+      0x01, # Flags
+      0x90, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # FunctionEntryPC: 0x1790
+      0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, # FunctionTypeID: 0x3ECBEEF531F74424
+
+      # --- bar ---
+      0x00, # Version
+      0x01, # Flags
+      0xA0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # FunctionEntryPC: 0x17A0
+      0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, # FunctionTypeID: 0x3ECBEEF531F74424
+
+      # --- baz ---
+      0x00, # Version
+      0x01, # Flags
+      0xB0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # FunctionEntryPC: 0x17B0
+      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30, # FunctionTypeID: 0x308E4B8159BC8654
+
+      # --- main ---
+      0x00, # Version
+      0x07, # Flags
+      0xC0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # FunctionEntryPC: 0x17C0
+      0xCA, 0xAF, 0x76, 0x9A, 0x60, 0x09, 0x68, 0xFA, # FunctionTypeID: 0xFA6809609A76AFCA
+
+      # Direct Callees
+      0x03, # NumDirectCallees
+      0x90, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 1: 0x1790 (foo)
+      0xA0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 2: 0x17A0 (bar)
+      0xB0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 3: 0x17B0 (baz)
+
+      # Indirect Callees
+      0x02, # NumIndirectTargetTypeIDs
+      0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, # TypeID 1
+      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30  # TypeID 2
+    ]
+Symbols:
+  - Name:     foo
+    Type:     STT_FUNC
+    Section:  .text
+    Value:    0x1790
+  - Name:     bar
+    Type:     STT_FUNC
+    Section:  .text
+    Value:    0x17A0
+  - Name:     baz
+    Type:     STT_FUNC
+    Section:  .text
+    Value:    0x17B0
+  - Name:     main
+    Type:     STT_FUNC
+    Section:  .text
+    Value:    0x17C0
+...
+
+## Check relocatable object file handling.
+# RUN: yaml2obj --docnum=2 %s -o %t2
+# RUN: llvm-readelf --call-graph-info %t2 2>&1 | count 0
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t2 2>&1 | \
+# RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM_RELOC -DFILE=%t2
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t2 2>&1 | \
+# RUN:   FileCheck %s --match-full-lines --check-prefix=JSON_RELOC -DFILE=%t2
+
+## We do not support GNU format console output for --call-graph-info as it is an LLVM only info.
+# GNU_RELOC-NOT: .
+
+# LLVM_RELOC:   CallGraph [
+# LLVM_RELOC-NEXT:   Function {
+# LLVM_RELOC-NEXT:     Name: foo
+# LLVM_RELOC-NEXT:     Version: 0
+# LLVM_RELOC-NEXT:     IsIndirectTarget: Yes
+# LLVM_RELOC-NEXT:     TypeId: 0xF85C699BB8EF20A2
+# LLVM_RELOC-NEXT:     NumDirectCallees: 0
+# LLVM_RELOC-NEXT:     DirectCallees [
+# LLVM_RELOC-NEXT:     ]
+# LLVM_RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM_RELOC-NEXT:     IndirectTypeIDs: []
+# LLVM_RELOC-NEXT:   }
+# LLVM_RELOC-NEXT:   Function {
+# LLVM_RELOC-NEXT:     Name: bar
+# LLVM_RELOC-NEXT:     Version: 0
+# LLVM_RELOC-NEXT:     IsIndirectTarget: Yes
+# LLVM_RELOC-NEXT:     TypeId: 0xF85C699BB8EF20A2
+# LLVM_RELOC-NEXT:     NumDirectCallees: 0
+# LLVM_RELOC-NEXT:     DirectCallees [
+# LLVM_RELOC-NEXT:     ]
+# LLVM_RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM_RELOC-NEXT:     IndirectTypeIDs: []
+# LLVM_RELOC-NEXT:   }
+# LLVM_RELOC-NEXT:   Function {
+# LLVM_RELOC-NEXT:     Name: baz
+# LLVM_RELOC-NEXT:     Version: 0
+# LLVM_RELOC-NEXT:     IsIndirectTarget: Yes
+# LLVM_RELOC-NEXT:     TypeId: 0x308E4B8159BC8654
+# LLVM_RELOC-NEXT:     NumDirectCallees: 0
+# LLVM_RELOC-NEXT:     DirectCallees [
+# LLVM_RELOC-NEXT:     ]
+# LLVM_RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM_RELOC-NEXT:     IndirectTypeIDs: []
+# LLVM_RELOC-NEXT:   }
+# LLVM_RELOC-NEXT:   Function {
+# LLVM_RELOC-NEXT:     Name: caller
+# LLVM_RELOC-NEXT:     Version: 0
+# LLVM_RELOC-NEXT:     IsIndirectTarget: Yes
+# LLVM_RELOC-NEXT:     TypeId: 0xA9494DEF81A01DC
+# LLVM_RELOC-NEXT:     NumDirectCallees: 3
+# LLVM_RELOC-NEXT:     DirectCallees [
+# LLVM_RELOC-NEXT:       {
+# LLVM_RELOC-NEXT:         Name: foo
+# LLVM_RELOC-NEXT:       }
+# LLVM_RELOC-NEXT:       {
+# LLVM_RELOC-NEXT:         Name: bar
+# LLVM_RELOC-NEXT:       }
+# LLVM_RELOC-NEXT:       {
+# LLVM_RELOC-NEXT:         Name: baz
+# LLVM_RELOC-NEXT:       }
+# LLVM_RELOC-NEXT:     ]
+# LLVM_RELOC-NEXT:     NumIndirectTargetTypeIDs: 2
+# LLVM_RELOC-NEXT:     IndirectTypeIDs: [0xF85C699BB8EF20A2, 0x308E4B8159BC8654]
+# LLVM_RELOC-NEXT:   }
+# LLVM_RELOC-NEXT: ]
+
+# JSON_RELOC:     "CallGraph": [
+# JSON_RELOC-NEXT:      {
+# JSON_RELOC-NEXT:        "Function": {
+# JSON_RELOC-NEXT:          "Name": "foo",
+# JSON_RELOC-NEXT:          "Version": 0,
+# JSON_RELOC-NEXT:          "IsIndirectTarget": true,
+# JSON_RELOC-NEXT:          "TypeId": 17896295136807035042,
+# JSON_RELOC-NEXT:          "NumDirectCallees": 0,
+# JSON_RELOC-NEXT:          "DirectCallees": [],
+# JSON_RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON_RELOC-NEXT:          "IndirectTypeIDs": []
+# JSON_RELOC-NEXT:        }
+# JSON_RELOC-NEXT:      },
+# JSON_RELOC-NEXT:      {
+# JSON_RELOC-NEXT:        "Function": {
+# JSON_RELOC-NEXT:          "Name": "bar",
+# JSON_RELOC-NEXT:          "Version": 0,
+# JSON_RELOC-NEXT:          "IsIndirectTarget": true,
+# JSON_RELOC-NEXT:          "TypeId": 17896295136807035042,
+# JSON_RELOC-NEXT:          "NumDirectCallees": 0,
+# JSON_RELOC-NEXT:          "DirectCallees": [],
+# JSON_RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON_RELOC-NEXT:          "IndirectTypeIDs": []
+# JSON_RELOC-NEXT:        }
+# JSON_RELOC-NEXT:      },
+# JSON_RELOC-NEXT:      {
+# JSON_RELOC-NEXT:        "Function": {
+# JSON_RELOC-NEXT:          "Name": "baz",
+# JSON_RELOC-NEXT:          "Version": 0,
+# JSON_RELOC-NEXT:          "IsIndirectTarget": true,
+# JSON_RELOC-NEXT:          "TypeId": 3498816979441845844,
+# JSON_RELOC-NEXT:          "NumDirectCallees": 0,
+# JSON_RELOC-NEXT:          "DirectCallees": [],
+# JSON_RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON_RELOC-NEXT:          "IndirectTypeIDs": []
+# JSON_RELOC-NEXT:        }
+# JSON_RELOC-NEXT:      },
+# JSON_RELOC-NEXT:      {
+# JSON_RELOC-NEXT:        "Function": {
+# JSON_RELOC-NEXT:          "Name": "caller",
+# JSON_RELOC-NEXT:          "Version": 0,
+# JSON_RELOC-NEXT:          "IsIndirectTarget": true,
+# JSON_RELOC-NEXT:          "TypeId": 762397922298560988,
+# JSON_RELOC-NEXT:          "NumDirectCallees": 3,
+# JSON_RELOC-NEXT:          "DirectCallees": [
+# JSON_RELOC-NEXT:            {
+# JSON_RELOC-NEXT:              "Name": "foo"
+# JSON_RELOC-NEXT:            },
+# JSON_RELOC-NEXT:            {
+# JSON_RELOC-NEXT:              "Name": "bar"
+# JSON_RELOC-NEXT:            },
+# JSON_RELOC-NEXT:            {
+# JSON_RELOC-NEXT:              "Name": "baz"
+# JSON_RELOC-NEXT:            }
+# JSON_RELOC-NEXT:          ],
+# JSON_RELOC-NEXT:          "NumIndirectTargetTypeIDs": 2,
+# JSON_RELOC-NEXT:          "IndirectTypeIDs": [
+# JSON_RELOC-NEXT:            17896295136807035042,
+# JSON_RELOC-NEXT:            3498816979441845844
+# JSON_RELOC-NEXT:          ]
+# JSON_RELOC-NEXT:        }
+# JSON_RELOC-NEXT:      }
+# JSON_RELOC-NEXT:    ]
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_REL
+  Machine:  EM_X86_64
+Sections:
+  - Name:   .text
+    Type:   SHT_PROGBITS
+    Size:   0x84
+  - Name:   .llvm.callgraph
+    Type:   SHT_LLVM_CALL_GRAPH
+    Flags:  [ SHF_LINK_ORDER ]
+    Link:   .text
+    ContentArray: [
+      # --- Entry 1: foo (foo) ---
+      # Offset 0x0
+      0x00, # Format Version
+      0x01, # Flags
+      # Offset 0x2 (Matches Reloc: foo)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Address of foo
+      0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, # TypeID of foo
+
+      # --- Entry 2: bar (bar) ---
+      # Offset 0x12
+      0x00, # Format Version
+      0x01, # Flags
+      # Offset 0x14 (Matches Reloc: bar)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Address of bar
+      0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, # TypeID of bar
+
+      # --- Entry 3: baz (baz) ---
+      # Offset 0x24
+      0x00, # Format Version
+      0x01, # Flags
+      # Offset 0x26 (Matches Reloc: baz)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Address of baz
+      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30, # TypeID of baz
+
+      # --- Entry 4: caller (caller) ---
+      # Offset 0x36
+      0x00, # Format Version
+      0x07, # Flags (HasDirectCallees | IsIndirectTarget | ...)
+      # Offset 0x38 (Matches Reloc: caller)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Address of caller
+      0xDC, 0x01, 0x1A, 0xF8, 0xDE, 0x94, 0x94, 0x0A, # TypeID of caller
+
+      # Direct Callees List
+      0x03, # NumDirectCallees (3)
+      # Offset 0x49 (Matches Reloc: foo)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 1: foo
+      # Offset 0x51 (Matches Reloc: bar)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 2: bar
+      # Offset 0x59 (Matches Reloc: baz)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 3: baz
+
+      # Indirect Callees List
+      0x02, # NumIndirectTargetTypeIDs (2)
+      0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, # Indirect TypeID 1 (matches foo/bar)
+      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30  # Indirect TypeID 2 (matches baz)
+    ]
+  - Name:   .rela.llvm.callgraph
+    Type:   SHT_RELA
+    Flags:  [ SHF_INFO_LINK ]
+    Info:   .llvm.callgraph
+    Relocations:
+      - Offset:  0x2
+        Symbol:  foo
+        Type:    R_X86_64_64
+      - Offset:  0x14
+        Symbol:  bar
+        Type:    R_X86_64_64
+      - Offset:  0x26
+        Symbol:  baz
+        Type:    R_X86_64_64
+      - Offset:  0x38
+        Symbol:  caller
+        Type:    R_X86_64_64
+      - Offset:  0x49
+        Symbol:  foo
+        Type:    R_X86_64_64
+      - Offset:  0x51
+        Symbol:  bar
+        Type:    R_X86_64_64
+      - Offset:  0x59
+        Symbol:  baz
+        Type:    R_X86_64_64
+Symbols:
+  - Name:  foo
+  - Name:  bar
+  - Name:  baz
+  - Name:  caller
+...
+
+## Check ARM 32-bit Thumb address handling.
+# RUN: yaml2obj --docnum=3 %s -o %t3
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t3 2>&1 | \
+# RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM_ARM_THUMB -DFILE=%t3
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t3 2>&1 | \
+# RUN:   FileCheck %s --match-full-lines --check-prefix=JSON_ARM_THUMB -DFILE=%t3
+
+# LLVM_ARM_THUMB:      CallGraph [
+# LLVM_ARM_THUMB-NEXT:   Function {
+# LLVM_ARM_THUMB-NEXT:     Name: foo
+# LLVM_ARM_THUMB-NEXT:     Version: 0
+# LLVM_ARM_THUMB-NEXT:     IsIndirectTarget: No
+# LLVM_ARM_THUMB-NEXT:     TypeId: 0x123456789ABCDEF0
+# LLVM_ARM_THUMB-NEXT:     NumDirectCallees: 0
+# LLVM_ARM_THUMB-NEXT:     DirectCallees [
+# LLVM_ARM_THUMB-NEXT:     ]
+# LLVM_ARM_THUMB-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM_ARM_THUMB-NEXT:     IndirectTypeIDs: []
+# LLVM_ARM_THUMB-NEXT:   }
+# LLVM_ARM_THUMB-NEXT: ]
+
+# JSON_ARM_THUMB:       "CallGraph": [
+# JSON_ARM_THUMB-NEXT:    {
+# JSON_ARM_THUMB-NEXT:      "Function": {
+# JSON_ARM_THUMB-NEXT:        "Name": "foo",
+# JSON_ARM_THUMB-NEXT:        "Version": 0,
+# JSON_ARM_THUMB-NEXT:        "IsIndirectTarget": false,
+# JSON_ARM_THUMB-NEXT:        "TypeId": 1311768467463790320,
+# JSON_ARM_THUMB-NEXT:        "NumDirectCallees": 0,
+# JSON_ARM_THUMB-NEXT:        "DirectCallees": [],
+# JSON_ARM_THUMB-NEXT:        "NumIndirectTargetTypeIDs": 0,
+# JSON_ARM_THUMB-NEXT:        "IndirectTypeIDs": []
+# JSON_ARM_THUMB-NEXT:      }
+# JSON_ARM_THUMB-NEXT:    }
+# JSON_ARM_THUMB-NEXT:  ]
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS32
+  Data:     ELFDATA2LSB
+  Type:     ET_REL
+  Machine:  EM_ARM
+Sections:
+  - Name:   .text
+    Type:   SHT_PROGBITS
+    Size:   0x100
+  - Name:   .llvm.callgraph
+    Type:   SHT_LLVM_CALL_GRAPH
+    Flags:  [ SHF_LINK_ORDER ]
+    Link:   .text
+    ContentArray: [
+      # --- foo+1 (Thumb address) ---
+      0x00, # Version
+      0x00, # Flags
+      0x01, 0x00, 0x00, 0x00, # FunctionEntryPC: 0x1 (relative to foo)
+      0xF0, 0xDE, 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12 # FunctionTypeID: 0x123456789ABCDEF0
+    ]
+  - Name:   .rela.llvm.callgraph
+    Type:   SHT_RELA
+    Flags:  [ SHF_INFO_LINK ]
+    Info:   .llvm.callgraph
+    Relocations:
+      - Offset:  0x2 # Offset to FunctionEntryPC
+        Symbol:  foo
+        Type:    R_ARM_ABS32
+Symbols:
+  - Name:     foo
+    Type:     STT_FUNC
+    Section:  .text
+    Value:    0x0 
+...
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 96c4668984965..7239230704678 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -22,6 +22,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
@@ -36,7 +37,6 @@
 #include "llvm/Object/ELF.h"
 #include "llvm/Object/ELFObjectFile.h"
 #include "llvm/Object/ELFTypes.h"
-#include "llvm/Object/Error.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Object/RelocationResolver.h"
 #include "llvm/Object/SFrameParser.h"
@@ -182,6 +182,16 @@ struct GroupSection {
   std::vector<GroupMember> Members;
 };
 
+// Per-function call graph information.
+struct FunctionCallgraphInfo {
+  uint64_t FunctionAddress;
+  uint8_t FormatVersionNumber;
+  bool IsIndirectTarget;
+  uint64_t FunctionTypeId;
+  SmallSet<uint64_t, 4> DirectCallees;
+  SmallSet<uint64_t, 4> IndirectTypeIDs;
+};
+
 namespace {
 
 struct NoteType {
@@ -441,6 +451,15 @@ 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 SHT_LLVM_CALL_GRAPH type 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 SHT_LLVM_CALL_GRAPH type section
+  // in the input file.
+  bool processCallGraphSection(const Elf_Shdr *CGSection);
 
 private:
   mutable SmallVector<std::optional<VersionEntry>, 0> VersionMap;
@@ -739,6 +758,7 @@ template <typename ELFT> class LLVMELFDumper : public ELFDumper<ELFT> {
   void printVersionDefinitionSection(const Elf_Shdr *Sec) override;
   void printVersionDependencySection(const Elf_Shdr *Sec) override;
   void printCGProfile() override;
+  void printCallGraphInfo() override;
   void printBBAddrMaps(bool PrettyPGOAnalysis) override;
   void printAddrsig() override;
   void printNotes() override;
@@ -5317,6 +5337,158 @@ template <class ELFT> void GNUELFDumper<ELFT>::printCGProfile() {
   OS << "GNUStyle::printCGProfile not implemented\n";
 }
 
+namespace callgraph {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+enum Flags : uint8_t {
+  None = 0,
+  IsIndirectTarget = 1u << 0,
+  HasDirectCallees = 1u << 1,
+  HasIndirectCallees = 1u << 2,
+  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue*/ HasIndirectCallees)
+};
+} // namespace callgraph
+
+template <class ELFT>
+bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
+  Expected<ArrayRef<uint8_t>> SectionBytesOrErr =
+      Obj.getSectionContents(*CGSection);
+  if (!SectionBytesOrErr) {
+    reportWarning(
+        createError("unable to read the SHT_LLVM_CALL_GRAPH type section " +
+                    toString(SectionBytesOrErr.takeError())),
+        FileName);
+    return false;
+  }
+
+  DataExtractor Data(SectionBytesOrErr.get(), Obj.isLE(),
+                     ObjF.getBytesInAddress());
+  DataExtractor::Cursor C(0);
+  uint64_t UnknownCount = 0;
+  while (C && C.tell() < CGSection->sh_size) {
+    uint8_t FormatVersionNumber = Data.getU8(C);
+    if (!C) {
+      reportWarning(createError("failed while reading FormatVersionNumber " +
+                                toString(C.takeError())),
+                    FileName);
+      return false;
+    }
+    if (FormatVersionNumber != 0) {
+      reportWarning(createError("unknown format version value [" +
+                                std::to_string(FormatVersionNumber) +
+                                "] in SHT_LLVM_CALL_GRAPH type section"),
+                    FileName);
+      return false;
+    }
+
+    uint8_t FlagsVal = Data.getU8(C);
+    if (!C) {
+      reportWarning(
+          createError("failed while reading call graph info's Flags " +
+                      toString(C.takeError())),
+          FileName);
+      return false;
+    }
+    callgraph::Flags CGFlags = static_cast<callgraph::Flags>(FlagsVal);
+    constexpr callgraph::Flags ValidFlags = callgraph::IsIndirectTarget |
+                                            callgraph::HasDirectCallees |
+                                            callgraph::HasIndirectCallees;
+    constexpr uint8_t ValidMask = static_cast<uint8_t>(ValidFlags);
+    if ((FlagsVal & ~ValidMask) != 0) {
+      reportWarning(createError("unexpected Flags value [" +
+                                std::to_string(FlagsVal) + "] "),
+                    FileName);
+      return false;
+    }
+
+    uint64_t FuncAddrOffset = C.tell();
+    uint64_t FuncAddr =
+        static_cast<uint64_t>(Data.getUnsigned(C, sizeof(typename ELFT::uint)));
+    if (!C) {
+      reportWarning(
+          createError(
+              "failed while reading call graph info function entry PC " +
+              toString(C.takeError())),
+          FileName);
+      return false;
+    }
+
+    bool IsETREL = this->Obj.getHeader().e_type == ELF::ET_REL;
+    // Create a new entry for this function.
+    FunctionCallgraphInfo CGInfo;
+    CGInfo.FunctionAddress = IsETREL ? FuncAddrOffset : FuncAddr;
+    CGInfo.FormatVersionNumber = FormatVersionNumber;
+    bool IsIndirectTarget =
+        (CGFlags & callgraph::IsIndirectTarget) != callgraph::None;
+    CGInfo.IsIndirectTarget = IsIndirectTarget;
+    uint64_t TypeId = Data.getU64(C);
+    if (!C) {
+      reportWarning(createError("failed while reading function type ID " +
+                                toString(C.takeError())),
+                    FileName);
+      return false;
+    }
+    CGInfo.FunctionTypeId = TypeId;
+    if (IsIndirectTarget && TypeId == 0)
+      ++UnknownCount;
+
+    if (CGFlags & callgraph::HasDirectCallees) {
+      // Read number of direct call sites for this function.
+      uint64_t NumDirectCallees = Data.getULEB128(C);
+      if (!C) {
+        reportWarning(
+            createError("failed while reading number of direct callees " +
+                        toString(C.takeError())),
+            FileName);
+        return false;
+      }
+      // Read unique direct callees and populate FuncCGInfos.
+      for (uint64_t I = 0; I < NumDirectCallees; ++I) {
+        uint64_t CalleeOffset = C.tell();
+        uint64_t Callee = static_cast<uint64_t>(
+            Data.getUnsigned(C, sizeof(typename ELFT::uint)));
+        if (!C) {
+          reportWarning(createError("failed while reading direct callee " +
+                                    toString(C.takeError())),
+                        FileName);
+          return false;
+        }
+        CGInfo.DirectCallees.insert((IsETREL ? CalleeOffset : Callee));
+      }
+    }
+
+    if (CGFlags & callgraph::HasIndirectCallees) {
+      uint64_t NumIndirectTargetTypeIDs = Data.getULEB128(C);
+      if (!C) {
+        reportWarning(
+            createError(
+                "failed while reading number of indirect target type IDs " +
+                toString(C.takeError())),
+            FileName);
+        return false;
+      }
+      // Read unique indirect target type IDs and populate FuncCGInfos.
+      for (uint64_t I = 0; I < NumIndirectTargetTypeIDs; ++I) {
+        uint64_t TargetType = Data.getU64(C);
+        if (!C) {
+          reportWarning(
+              createError("failed while reading indirect target type ID " +
+                          toString(C.takeError())),
+              FileName);
+          return false;
+        }
+        CGInfo.IndirectTypeIDs.insert(TargetType);
+      }
+    }
+    FuncCGInfos.push_back(CGInfo);
+  }
+
+  if (UnknownCount)
+    reportUniqueWarning(
+        "SHT_LLVM_CALL_GRAPH type section has unknown type id for " +
+        std::to_string(UnknownCount) + " indirect targets");
+  return true;
+}
+
 template <class ELFT>
 void GNUELFDumper<ELFT>::printBBAddrMaps(bool /*PrettyPGOAnalysis*/) {
   OS << "GNUStyle::printBBAddrMaps not implemented\n";
@@ -8148,6 +8320,110 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCGProfile() {
   }
 }
 
+template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
+  // Call graph section is of type SHT_LLVM_CALL_GRAPH. Typically named
+  // ".llvm.callgraph". First fetch the section by its type.
+  using Elf_Shdr = typename ELFT::Shdr;
+  Expected<MapVector<const Elf_Shdr *, const Elf_Shdr *>> MapOrErr =
+      this->Obj.getSectionAndRelocations([](const Elf_Shdr &Sec) {
+        return Sec.sh_type == ELF::SHT_LLVM_CALL_GRAPH;
+      });
+  if (!MapOrErr || MapOrErr->empty()) {
+    reportWarning(createError("no SHT_LLVM_CALL_GRAPH section found " +
+                              toString(MapOrErr.takeError())),
+                  this->FileName);
+    return;
+  }
+  if (!this->processCallGraphSection(MapOrErr->begin()->first) ||
+      this->FuncCGInfos.empty())
+    return;
+
+  std::vector<Relocation<ELFT>> Relocations;
+  const Elf_Shdr *RelocSymTab = nullptr;
+  if (this->Obj.getHeader().e_type == ELF::ET_REL) {
+    const Elf_Shdr *CGRelSection = MapOrErr->front().second;
+    if (CGRelSection) {
+      this->forEachRelocationDo(
+          *CGRelSection, [&](const Relocation<ELFT> &R, unsigned Ndx,
+                             const Elf_Shdr &Sec, const Elf_Shdr *SymTab) {
+            RelocSymTab = SymTab;
+            Relocations.push_back(R);
+          });
+      llvm::stable_sort(Relocations, [](const auto &LHS, const auto &RHS) {
+        return LHS.Offset < RHS.Offset;
+      });
+    }
+  }
+
+  auto GetFunctionNames = [&](uint64_t FuncAddr) {
+    SmallVector<uint32_t> FuncSymIndexes =
+        this->getSymbolIndexesForFunctionAddress(FuncAddr, std::nullopt);
+    SmallVector<std::string> FuncSymNames;
+    FuncSymNames.reserve(FuncSymIndexes.size());
+    for (uint32_t Index : FuncSymIndexes)
+      FuncSymNames.push_back(this->getStaticSymbolName(Index));
+    return FuncSymNames;
+  };
+
+  auto PrintNonRelocatableFuncSymbol = [&](uint64_t FuncEntryPC) {
+    SmallVector<std::string> FuncSymNames = GetFunctionNames(FuncEntryPC);
+    if (!FuncSymNames.empty())
+      W.printList("Names", FuncSymNames);
+    W.printHex("Address", FuncEntryPC);
+  };
+
+  auto PrintRelocatableFuncSymbol = [&](uint64_t RelocOffset) {
+    auto R = llvm::find_if(Relocations, [&](const Relocation<ELFT> &R) {
+      return R.Offset == RelocOffset;
+    });
+    if (R == Relocations.end()) {
+      this->reportUniqueWarning("unknown relocation at offset " +
+                                Twine(RelocOffset));
+      return;
+    }
+    Expected<RelSymbol<ELFT>> RelSymOrErr =
+        this->getRelocationTarget(*R, RelocSymTab);
+    if (!RelSymOrErr) {
+      this->reportUniqueWarning(RelSymOrErr.takeError());
+      return;
+    }
+    if (!RelSymOrErr->Name.empty())
+      W.printString("Name", RelSymOrErr->Name);
+  };
+
+  auto PrintFunc = [&](uint64_t FuncPC) {
+    uint64_t FuncEntryPC = FuncPC;
+    // Clear Thumb bit if it was set before symbol lookup.
+    if (this->Obj.getHeader().e_machine == ELF::EM_ARM)
+      FuncEntryPC = FuncPC & ~1;
+    if (this->Obj.getHeader().e_type == ELF::ET_REL)
+      PrintRelocatableFuncSymbol(FuncEntryPC);
+    else
+      PrintNonRelocatableFuncSymbol(FuncEntryPC);
+  };
+
+  ListScope CGI(W, "CallGraph");
+  for (const auto &CGInfo : this->FuncCGInfos) {
+    DictScope D(W, "Function");
+    PrintFunc(CGInfo.FunctionAddress);
+    W.printNumber("Version", CGInfo.FormatVersionNumber);
+    W.printBoolean("IsIndirectTarget", CGInfo.IsIndirectTarget);
+    W.printHex("TypeId", CGInfo.FunctionTypeId);
+    W.printNumber("NumDirectCallees", CGInfo.DirectCallees.size());
+    {
+      ListScope DCs(W, "DirectCallees");
+      for (auto CalleePC : CGInfo.DirectCallees) {
+        DictScope D(W);
+        PrintFunc(CalleePC);
+      }
+    }
+    W.printNumber("NumIndirectTargetTypeIDs", CGInfo.IndirectTypeIDs.size());
+    SmallVector<uint64_t, 4> IndirectTypeIdsList(CGInfo.IndirectTypeIDs.begin(),
+                                                 CGInfo.IndirectTypeIDs.end());
+    W.printHexList("IndirectTypeIDs", ArrayRef(IndirectTypeIdsList));
+  }
+}
+
 template <class ELFT>
 void LLVMELFDumper<ELFT>::printBBAddrMaps(bool PrettyPGOAnalysis) {
   bool IsRelocatable = this->Obj.getHeader().e_type == ELF::ET_REL;
diff --git a/llvm/tools/llvm-readobj/ObjDumper.h b/llvm/tools/llvm-readobj/ObjDumper.h
index d26439435a82b..0dba8252fd466 100644
--- a/llvm/tools/llvm-readobj/ObjDumper.h
+++ b/llvm/tools/llvm-readobj/ObjDumper.h
@@ -130,6 +130,7 @@ class ObjDumper {
   virtual void printGroupSections() {}
   virtual void printHashHistograms() {}
   virtual void printCGProfile() {}
+  virtual void printCallGraphInfo() {}
   // If PrettyPGOAnalysis is true, prints BFI as relative frequency and BPI as
   // percentage. Otherwise raw values are displayed.
   virtual void printBBAddrMaps(bool PrettyPGOAnalysis) {}
diff --git a/llvm/tools/llvm-readobj/Opts.td b/llvm/tools/llvm-readobj/Opts.td
index 97d5d7f96dc32..f489e564d3182 100644
--- a/llvm/tools/llvm-readobj/Opts.td
+++ b/llvm/tools/llvm-readobj/Opts.td
@@ -20,6 +20,7 @@ def all : FF<"all", "Equivalent to setting: --file-header, --program-headers, --
 def arch_specific : FF<"arch-specific", "Display architecture-specific information">;
 def bb_addr_map : FF<"bb-addr-map", "Display the BB address map section">;
 def pretty_pgo_analysis_map : FF<"pretty-pgo-analysis-map", "Display PGO analysis values with formatting rather than raw numbers">;
+def call_graph_info : FF<"call-graph-info", "Display call graph information">;
 def cg_profile : FF<"cg-profile", "Display call graph profile section">;
 def decompress : FF<"decompress", "Dump decompressed section content when used with -x or -p">;
 defm demangle : BB<"demangle", "Demangle symbol names", "Do not demangle symbol names (default)">;
diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp
index 5327731805010..95fb283940c17 100644
--- a/llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -99,6 +99,7 @@ static bool ArchSpecificInfo;
 static bool BBAddrMap;
 static bool PrettyPGOAnalysisMap;
 bool ExpandRelocs;
+static bool CallGraphInfo;
 static bool CGProfile;
 static bool Decompress;
 bool Demangle;
@@ -222,6 +223,7 @@ static void parseOptions(const opt::InputArgList &Args) {
     WithColor::warning(errs(), ToolName)
         << "--bb-addr-map must be enabled for --pretty-pgo-analysis-map to "
            "have an effect\n";
+  opts::CallGraphInfo = Args.hasArg(OPT_call_graph_info);
   opts::CGProfile = Args.hasArg(OPT_cg_profile);
   opts::Decompress = Args.hasArg(OPT_decompress);
   opts::Demangle = Args.hasFlag(OPT_demangle, OPT_no_demangle, false);
@@ -478,6 +480,8 @@ static void dumpObject(ObjectFile &Obj, ScopedPrinter &Writer,
       Dumper->printHashHistograms();
     if (opts::CGProfile)
       Dumper->printCGProfile();
+    if (opts::CallGraphInfo)
+      Dumper->printCallGraphInfo();
     if (opts::BBAddrMap)
       Dumper->printBBAddrMaps(opts::PrettyPGOAnalysisMap);
     if (opts::Addrsig)

>From cd35f6f645ec4e7c352c509f73cb1ef9f8264d0d Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Thu, 15 Jan 2026 23:41:28 +0000
Subject: [PATCH 02/22] Use readobj instead of readelf

---
 .../ELF/call-graph-info-warn-malformed.test   | 46 +++++++++----------
 .../llvm-readobj/ELF/call-graph-info.test     | 16 +++----
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index e1396cabb8784..3a9229810eb05 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -4,9 +4,9 @@
 
 ## Tests that --call-graph-info warns if there is no section of type SHT_LLVM_CALL_GRAPH.
 # RUN: yaml2obj --docnum=1 %s -o %t1
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t1 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t1 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t1 --check-prefix=WARN_NO_SECTION
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t1 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t1 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t1 --check-prefix=WARN_NO_SECTION
 
 # WARN_NO_SECTION: warning: '[[FILE]]': no SHT_LLVM_CALL_GRAPH section found
@@ -21,9 +21,9 @@ FileHeader:
 
 ## Check format version number.
 # RUN: yaml2obj --docnum=2 %s -o %t2
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t2 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t2 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t2 --check-prefix=WARN_FMT_VERSION
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t2 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t2 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t2 --check-prefix=WARN_FMT_VERSION
 
 # WARN_FMT_VERSION: warning: '[[FILE]]': unknown format version value [1] in SHT_LLVM_CALL_GRAPH type section
@@ -50,9 +50,9 @@ Symbols:
 
 ## Check missing flags.
 # RUN: yaml2obj --docnum=3 %s -o %t3
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t3 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t3 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t3 --check-prefix=WARN_MISSING_FLAG
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t3 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t3 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t3 --check-prefix=WARN_MISSING_FLAG
 
 # WARN_MISSING_FLAG: warning: '[[FILE]]': failed while reading call graph info's Flags unexpected end of data at offset 0x1 while reading [0x1, 0x2)
@@ -80,9 +80,9 @@ Symbols:
 
 ## Check Flags.
 # RUN: yaml2obj --docnum=4 %s -o %t4
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t4 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t4 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t4 --check-prefix=WARN_FLAG
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t4 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t4 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t4 --check-prefix=WARN_FLAG
 
 # WARN_FLAG: warning: '[[FILE]]': unexpected Flags value [8]
@@ -110,9 +110,9 @@ Symbols:
 
 ## Check missing function entry PC.
 # RUN: yaml2obj --docnum=5 %s -o %t5
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t5 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t5 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t5 --check-prefix=WARN_MISSING_PC
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t5 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t5 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t5 --check-prefix=WARN_MISSING_PC
 
 # WARN_MISSING_PC: warning: '[[FILE]]': failed while reading call graph info function entry PC unexpected end of data at offset 0x2 while reading [0x2, 0xa)
@@ -141,9 +141,9 @@ Symbols:
 
 ## Check missing function Type ID.
 # RUN: yaml2obj --docnum=6 %s -o %t6
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t6 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t6 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN_MISSING_TYPEID
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t6 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t6 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN_MISSING_TYPEID
 
 # WARN_MISSING_TYPEID: warning: '[[FILE]]': failed while reading function type ID unexpected end of data at offset 0xa while reading [0xa, 0x12)
@@ -173,9 +173,9 @@ Symbols:
 
 ## Check missing number of direct callees.
 # RUN: yaml2obj --docnum=7 %s -o %t7
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t7 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t7 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN_MISSING_DIRECT
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t7 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t7 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN_MISSING_DIRECT
 
 # WARN_MISSING_DIRECT: warning: '[[FILE]]': failed while reading number of direct callees unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
@@ -206,9 +206,9 @@ Symbols:
 
 ## Check missing direct callee.
 # RUN: yaml2obj --docnum=8 %s -o %t8
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t8 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t8 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN_MISSING_CALLEE
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t8 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t8 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN_MISSING_CALLEE
 
 # WARN_MISSING_CALLEE: warning: '[[FILE]]': failed while reading direct callee unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
@@ -240,9 +240,9 @@ Symbols:
 
 ## Check missing number of indirect target type IDs.
 # RUN: yaml2obj --docnum=9 %s -o %t9
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t9 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t9 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t9 --check-prefix=WARN_MISSING_NUM_INDIRECT
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t9 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t9 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t9 --check-prefix=WARN_MISSING_NUM_INDIRECT
 
 # WARN_MISSING_NUM_INDIRECT: warning: '[[FILE]]': failed while reading number of indirect target type IDs unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
@@ -273,9 +273,9 @@ Symbols:
 
 ## Check missing indirect target type ID.
 # RUN: yaml2obj --docnum=10 %s -o %t10
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t10 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t10 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t10 --check-prefix=WARN_MISSING_INDIRECT_TARGET_TYPE_ID
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t10 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t10 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t10 --check-prefix=WARN_MISSING_INDIRECT_TARGET_TYPE_ID
 
 # WARN_MISSING_INDIRECT_TARGET_TYPE_ID: warning: '[[FILE]]': failed while reading indirect target type ID unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
@@ -307,10 +307,10 @@ Symbols:
 
 ## Check missing relocation information.
 # RUN: yaml2obj --docnum=11 %s -o %t11
-# RUN: llvm-readelf --call-graph-info %t11 2>&1 | count 0
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t11 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=GNU --call-graph-info %t11 2>&1 | count 0
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t11 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t11 --check-prefix=WARN_NO_RELOC
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t11 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t11 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t11 --check-prefix=WARN_NO_RELOC
 
 # WARN_NO_RELOC: warning: '[[FILE]]': SHT_LLVM_CALL_GRAPH type section has unknown type id for 2 indirect targets
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
index 79262101488a4..1f0836c0cd39b 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
@@ -2,10 +2,10 @@
 
 ## Check non-relocatable object file handling.
 # RUN: yaml2obj --docnum=1 %s -o %t1
-# RUN: llvm-readelf --call-graph-info %t1 2>&1 | count 0
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t1 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=GNU --call-graph-info %t1 2>&1 | count 0
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t1 2>&1 | \
 # RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM_NONRELOC -DFILE=%t1
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t1 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t1 2>&1 | \
 # RUN:   FileCheck %s --match-full-lines --check-prefix=JSON_NONRELOC -DFILE=%t1
 
 ## We do not support GNU format console output for --call-graph-info as it is an LLVM only info.
@@ -231,10 +231,10 @@ Symbols:
 
 ## Check relocatable object file handling.
 # RUN: yaml2obj --docnum=2 %s -o %t2
-# RUN: llvm-readelf --call-graph-info %t2 2>&1 | count 0
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t2 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=GNU --call-graph-info %t2 2>&1 | count 0
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t2 2>&1 | \
 # RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM_RELOC -DFILE=%t2
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t2 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t2 2>&1 | \
 # RUN:   FileCheck %s --match-full-lines --check-prefix=JSON_RELOC -DFILE=%t2
 
 ## We do not support GNU format console output for --call-graph-info as it is an LLVM only info.
@@ -456,9 +456,9 @@ Symbols:
 
 ## Check ARM 32-bit Thumb address handling.
 # RUN: yaml2obj --docnum=3 %s -o %t3
-# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t3 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t3 2>&1 | \
 # RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM_ARM_THUMB -DFILE=%t3
-# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t3 2>&1 | \
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t3 2>&1 | \
 # RUN:   FileCheck %s --match-full-lines --check-prefix=JSON_ARM_THUMB -DFILE=%t3
 
 # LLVM_ARM_THUMB:      CallGraph [

>From f96e5fc11eccb8a00069fe2506cad9dab7d64d92 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Thu, 15 Jan 2026 23:46:31 +0000
Subject: [PATCH 03/22] Remove unnecessary yaml parts

---
 .../llvm-readobj/ELF/call-graph-info-warn-malformed.test     | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index 3a9229810eb05..a537ce10b409c 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -349,10 +349,7 @@ Sections:
         '10', '0', '0', '0', '0', '0', '0', '0', # baz()'s address
         '32', '0', '0', '0', '0', '0', '0', '0', # baz()'s TypeID Unknown
       ]
-  - Name:   .rela.llvm.callgraph
-    Type:   SHT_RELA
-    Flags:  [ SHF_INFO_LINK ]
-    Link:   .symtab
+  - Type:   SHT_RELA
     Relocations:
       # 1. Pointer to foo() definition
       - Offset: 0x2

>From 6f2a3a80a62b6e19536a34965e0ed097bca0a302 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Jan 2026 00:13:59 +0000
Subject: [PATCH 04/22] Address review comments -- underscore to dash. Use
 twine.

---
 .../ELF/call-graph-info-warn-malformed.test   |  74 +--
 .../llvm-readobj/ELF/call-graph-info.test     | 600 +++++++++---------
 llvm/tools/llvm-readobj/ELFDumper.cpp         |   2 +-
 3 files changed, 335 insertions(+), 341 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index a537ce10b409c..960b49ef0faf2 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -5,11 +5,11 @@
 ## Tests that --call-graph-info warns if there is no section of type SHT_LLVM_CALL_GRAPH.
 # RUN: yaml2obj --docnum=1 %s -o %t1
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t1 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t1 --check-prefix=WARN_NO_SECTION
+# RUN:   FileCheck %s -DFILE=%t1 --check-prefix=WARN-NO-SECTION
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t1 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t1 --check-prefix=WARN_NO_SECTION
+# RUN:   FileCheck %s -DFILE=%t1 --check-prefix=WARN-NO-SECTION
 
-# WARN_NO_SECTION: warning: '[[FILE]]': no SHT_LLVM_CALL_GRAPH section found
+# WARN-NO-SECTION: warning: '[[FILE]]': no SHT_LLVM_CALL_GRAPH section found
 
 --- !ELF
 FileHeader:
@@ -22,11 +22,11 @@ FileHeader:
 ## Check format version number.
 # RUN: yaml2obj --docnum=2 %s -o %t2
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t2 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t2 --check-prefix=WARN_FMT_VERSION
+# RUN:   FileCheck %s -DFILE=%t2 --check-prefix=WARN-FMT-VERSION
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t2 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t2 --check-prefix=WARN_FMT_VERSION
+# RUN:   FileCheck %s -DFILE=%t2 --check-prefix=WARN-FMT-VERSION
 
-# WARN_FMT_VERSION: warning: '[[FILE]]': unknown format version value [1] in SHT_LLVM_CALL_GRAPH type section
+# WARN-FMT-VERSION: warning: '[[FILE]]': unknown format version value [1] in SHT_LLVM_CALL_GRAPH type section
 
 --- !ELF
 FileHeader:
@@ -51,11 +51,11 @@ Symbols:
 ## Check missing flags.
 # RUN: yaml2obj --docnum=3 %s -o %t3
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t3 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t3 --check-prefix=WARN_MISSING_FLAG
+# RUN:   FileCheck %s -DFILE=%t3 --check-prefix=WARN-MISSING-FLAG
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t3 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t3 --check-prefix=WARN_MISSING_FLAG
+# RUN:   FileCheck %s -DFILE=%t3 --check-prefix=WARN-MISSING-FLAG
 
-# WARN_MISSING_FLAG: warning: '[[FILE]]': failed while reading call graph info's Flags unexpected end of data at offset 0x1 while reading [0x1, 0x2)
+# WARN-MISSING-FLAG: warning: '[[FILE]]': failed while reading call graph info's Flags unexpected end of data at offset 0x1 while reading [0x1, 0x2)
 
 --- !ELF
 FileHeader:
@@ -81,11 +81,11 @@ Symbols:
 ## Check Flags.
 # RUN: yaml2obj --docnum=4 %s -o %t4
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t4 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t4 --check-prefix=WARN_FLAG
+# RUN:   FileCheck %s -DFILE=%t4 --check-prefix=WARN-FLAG
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t4 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t4 --check-prefix=WARN_FLAG
+# RUN:   FileCheck %s -DFILE=%t4 --check-prefix=WARN-FLAG
 
-# WARN_FLAG: warning: '[[FILE]]': unexpected Flags value [8]
+# WARN-FLAG: warning: '[[FILE]]': unexpected Flags value [8]
 
 --- !ELF
 FileHeader:
@@ -111,11 +111,11 @@ Symbols:
 ## Check missing function entry PC.
 # RUN: yaml2obj --docnum=5 %s -o %t5
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t5 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t5 --check-prefix=WARN_MISSING_PC
+# RUN:   FileCheck %s -DFILE=%t5 --check-prefix=WARN-MISSING-PC
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t5 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t5 --check-prefix=WARN_MISSING_PC
+# RUN:   FileCheck %s -DFILE=%t5 --check-prefix=WARN-MISSING-PC
 
-# WARN_MISSING_PC: warning: '[[FILE]]': failed while reading call graph info function entry PC unexpected end of data at offset 0x2 while reading [0x2, 0xa)
+# WARN-MISSING-PC: warning: '[[FILE]]': failed while reading call graph info function entry PC unexpected end of data at offset 0x2 while reading [0x2, 0xa)
 
 --- !ELF
 FileHeader:
@@ -142,11 +142,11 @@ Symbols:
 ## Check missing function Type ID.
 # RUN: yaml2obj --docnum=6 %s -o %t6
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t6 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN_MISSING_TYPEID
+# RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN-MISSING-TYPEID
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t6 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN_MISSING_TYPEID
+# RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN-MISSING-TYPEID
 
-# WARN_MISSING_TYPEID: warning: '[[FILE]]': failed while reading function type ID unexpected end of data at offset 0xa while reading [0xa, 0x12)
+# WARN-MISSING-TYPEID: warning: '[[FILE]]': failed while reading function type ID unexpected end of data at offset 0xa while reading [0xa, 0x12)
 
 --- !ELF
 FileHeader:
@@ -174,11 +174,11 @@ Symbols:
 ## Check missing number of direct callees.
 # RUN: yaml2obj --docnum=7 %s -o %t7
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t7 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN_MISSING_DIRECT
+# RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN-MISSING-DIRECT
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t7 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN_MISSING_DIRECT
+# RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN-MISSING-DIRECT
 
-# WARN_MISSING_DIRECT: warning: '[[FILE]]': failed while reading number of direct callees unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
+# WARN-MISSING-DIRECT: warning: '[[FILE]]': failed while reading number of direct callees unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
 
 --- !ELF
 FileHeader:
@@ -207,11 +207,11 @@ Symbols:
 ## Check missing direct callee.
 # RUN: yaml2obj --docnum=8 %s -o %t8
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t8 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN_MISSING_CALLEE
+# RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN-MISSING-CALLEE
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t8 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN_MISSING_CALLEE
+# RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN-MISSING-CALLEE
 
-# WARN_MISSING_CALLEE: warning: '[[FILE]]': failed while reading direct callee unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
+# WARN-MISSING-CALLEE: warning: '[[FILE]]': failed while reading direct callee unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
 
 --- !ELF
 FileHeader:
@@ -241,11 +241,11 @@ Symbols:
 ## Check missing number of indirect target type IDs.
 # RUN: yaml2obj --docnum=9 %s -o %t9
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t9 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t9 --check-prefix=WARN_MISSING_NUM_INDIRECT
+# RUN:   FileCheck %s -DFILE=%t9 --check-prefix=WARN-MISSING-NUM-INDIRECT
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t9 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t9 --check-prefix=WARN_MISSING_NUM_INDIRECT
+# RUN:   FileCheck %s -DFILE=%t9 --check-prefix=WARN-MISSING-NUM-INDIRECT
 
-# WARN_MISSING_NUM_INDIRECT: warning: '[[FILE]]': failed while reading number of indirect target type IDs unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
+# WARN-MISSING-NUM-INDIRECT: warning: '[[FILE]]': failed while reading number of indirect target type IDs unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
 
 --- !ELF
 FileHeader:
@@ -274,11 +274,11 @@ Symbols:
 ## Check missing indirect target type ID.
 # RUN: yaml2obj --docnum=10 %s -o %t10
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t10 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t10 --check-prefix=WARN_MISSING_INDIRECT_TARGET_TYPE_ID
+# RUN:   FileCheck %s -DFILE=%t10 --check-prefix=WARN-MISSING-INDIRECT-TARGET-TYPE-ID
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t10 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t10 --check-prefix=WARN_MISSING_INDIRECT_TARGET_TYPE_ID
+# RUN:   FileCheck %s -DFILE=%t10 --check-prefix=WARN-MISSING-INDIRECT-TARGET-TYPE-ID
 
-# WARN_MISSING_INDIRECT_TARGET_TYPE_ID: warning: '[[FILE]]': failed while reading indirect target type ID unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
+# WARN-MISSING-INDIRECT-TARGET-TYPE-ID: warning: '[[FILE]]': failed while reading indirect target type ID unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
 
 --- !ELF
 FileHeader:
@@ -309,15 +309,15 @@ Symbols:
 # RUN: yaml2obj --docnum=11 %s -o %t11
 # RUN: llvm-readobj --elf-output-style=GNU --call-graph-info %t11 2>&1 | count 0
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t11 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t11 --check-prefix=WARN_NO_RELOC
+# RUN:   FileCheck %s -DFILE=%t11 --check-prefix=WARN-NO-RELOC
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t11 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t11 --check-prefix=WARN_NO_RELOC
+# RUN:   FileCheck %s -DFILE=%t11 --check-prefix=WARN-NO-RELOC
 
-# WARN_NO_RELOC: warning: '[[FILE]]': SHT_LLVM_CALL_GRAPH type section has unknown type id for 2 indirect targets
-# WARN_NO_RELOC: warning: '[[FILE]]': unknown relocation at offset 2
-# WARN_NO_RELOC: warning: '[[FILE]]': unknown relocation at offset 19
-# WARN_NO_RELOC: warning: '[[FILE]]': unknown relocation at offset 29
-# WARN_NO_RELOC: warning: '[[FILE]]': unknown relocation at offset 56
+# WARN-NO-RELOC: warning: '[[FILE]]': SHT_LLVM_CALL_GRAPH type section has unknown type id for 2 indirect targets
+# WARN-NO-RELOC: warning: '[[FILE]]': unknown relocation at offset 2
+# WARN-NO-RELOC: warning: '[[FILE]]': unknown relocation at offset 19
+# WARN-NO-RELOC: warning: '[[FILE]]': unknown relocation at offset 29
+# WARN-NO-RELOC: warning: '[[FILE]]': unknown relocation at offset 56
 
 --- !ELF
 FileHeader:
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
index 1f0836c0cd39b..cb60ec760de58 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
@@ -4,160 +4,157 @@
 # RUN: yaml2obj --docnum=1 %s -o %t1
 # RUN: llvm-readobj --elf-output-style=GNU --call-graph-info %t1 2>&1 | count 0
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t1 2>&1 | \
-# RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM_NONRELOC -DFILE=%t1
+# RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM-NONRELOC -DFILE=%t1
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t1 2>&1 | \
-# RUN:   FileCheck %s --match-full-lines --check-prefix=JSON_NONRELOC -DFILE=%t1
+# RUN:   FileCheck %s --match-full-lines --check-prefix=JSON-NONRELOC -DFILE=%t1
 
-## We do not support GNU format console output for --call-graph-info as it is an LLVM only info.
-# GNU_NONRELOC-NOT: .
+# LLVM-NONRELOC:      CallGraph [
+# LLVM-NONRELOC-NEXT:     Function {
+# LLVM-NONRELOC-NEXT:       Names: [foo]
+# LLVM-NONRELOC-NEXT:       Address: 0x1790
+# LLVM-NONRELOC-NEXT:       Version: 0
+# LLVM-NONRELOC-NEXT:       IsIndirectTarget: Yes
+# LLVM-NONRELOC-NEXT:       TypeId: 0x3ECBEEF531F74424
+# LLVM-NONRELOC-NEXT:       NumDirectCallees: 0
+# LLVM-NONRELOC-NEXT:       DirectCallees [
+# LLVM-NONRELOC-NEXT:       ]
+# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
+# LLVM-NONRELOC-NEXT:       IndirectTypeIDs: []
+# LLVM-NONRELOC-NEXT:     }
+# LLVM-NONRELOC-NEXT:     Function {
+# LLVM-NONRELOC-NEXT:       Names: [bar]
+# LLVM-NONRELOC-NEXT:       Address: 0x17A0
+# LLVM-NONRELOC-NEXT:       Version: 0
+# LLVM-NONRELOC-NEXT:       IsIndirectTarget: Yes
+# LLVM-NONRELOC-NEXT:       TypeId: 0x3ECBEEF531F74424
+# LLVM-NONRELOC-NEXT:       NumDirectCallees: 0
+# LLVM-NONRELOC-NEXT:       DirectCallees [
+# LLVM-NONRELOC-NEXT:       ]
+# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
+# LLVM-NONRELOC-NEXT:       IndirectTypeIDs: []
+# LLVM-NONRELOC-NEXT:     }
+# LLVM-NONRELOC-NEXT:     Function {
+# LLVM-NONRELOC-NEXT:       Names: [baz]
+# LLVM-NONRELOC-NEXT:       Address: 0x17B0
+# LLVM-NONRELOC-NEXT:       Version: 0
+# LLVM-NONRELOC-NEXT:       IsIndirectTarget: Yes
+# LLVM-NONRELOC-NEXT:       TypeId: 0x308E4B8159BC8654
+# LLVM-NONRELOC-NEXT:       NumDirectCallees: 0
+# LLVM-NONRELOC-NEXT:       DirectCallees [
+# LLVM-NONRELOC-NEXT:       ]
+# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
+# LLVM-NONRELOC-NEXT:       IndirectTypeIDs: []
+# LLVM-NONRELOC-NEXT:     }
+# LLVM-NONRELOC-NEXT:     Function {
+# LLVM-NONRELOC-NEXT:       Names: [main]
+# LLVM-NONRELOC-NEXT:       Address: 0x17C0
+# LLVM-NONRELOC-NEXT:       Version: 0
+# LLVM-NONRELOC-NEXT:       IsIndirectTarget: Yes
+# LLVM-NONRELOC-NEXT:       TypeId: 0xFA6809609A76AFCA
+# LLVM-NONRELOC-NEXT:       NumDirectCallees: 3
+# LLVM-NONRELOC-NEXT:       DirectCallees [
+# LLVM-NONRELOC-NEXT:         {
+# LLVM-NONRELOC-NEXT:           Names: [foo]
+# LLVM-NONRELOC-NEXT:           Address: 0x1790
+# LLVM-NONRELOC-NEXT:         }
+# LLVM-NONRELOC-NEXT:         {
+# LLVM-NONRELOC-NEXT:           Names: [bar]
+# LLVM-NONRELOC-NEXT:           Address: 0x17A0
+# LLVM-NONRELOC-NEXT:         }
+# LLVM-NONRELOC-NEXT:         {
+# LLVM-NONRELOC-NEXT:           Names: [baz]
+# LLVM-NONRELOC-NEXT:           Address: 0x17B0
+# LLVM-NONRELOC-NEXT:         }
+# LLVM-NONRELOC-NEXT:       ]
+# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 2
+# LLVM-NONRELOC-NEXT:       IndirectTypeIDs: [0x3ECBEEF531F74424, 0x308E4B8159BC8654]
+# LLVM-NONRELOC-NEXT:     }
+# LLVM-NONRELOC-NEXT:   ]
 
-# LLVM_NONRELOC:      CallGraph [
-# LLVM_NONRELOC-NEXT:     Function {
-# LLVM_NONRELOC-NEXT:       Names: [foo]
-# LLVM_NONRELOC-NEXT:       Address: 0x1790
-# LLVM_NONRELOC-NEXT:       Version: 0
-# LLVM_NONRELOC-NEXT:       IsIndirectTarget: Yes
-# LLVM_NONRELOC-NEXT:       TypeId: 0x3ECBEEF531F74424
-# LLVM_NONRELOC-NEXT:       NumDirectCallees: 0
-# LLVM_NONRELOC-NEXT:       DirectCallees [
-# LLVM_NONRELOC-NEXT:       ]
-# LLVM_NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
-# LLVM_NONRELOC-NEXT:       IndirectTypeIDs: []
-# LLVM_NONRELOC-NEXT:     }
-# LLVM_NONRELOC-NEXT:     Function {
-# LLVM_NONRELOC-NEXT:       Names: [bar]
-# LLVM_NONRELOC-NEXT:       Address: 0x17A0
-# LLVM_NONRELOC-NEXT:       Version: 0
-# LLVM_NONRELOC-NEXT:       IsIndirectTarget: Yes
-# LLVM_NONRELOC-NEXT:       TypeId: 0x3ECBEEF531F74424
-# LLVM_NONRELOC-NEXT:       NumDirectCallees: 0
-# LLVM_NONRELOC-NEXT:       DirectCallees [
-# LLVM_NONRELOC-NEXT:       ]
-# LLVM_NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
-# LLVM_NONRELOC-NEXT:       IndirectTypeIDs: []
-# LLVM_NONRELOC-NEXT:     }
-# LLVM_NONRELOC-NEXT:     Function {
-# LLVM_NONRELOC-NEXT:       Names: [baz]
-# LLVM_NONRELOC-NEXT:       Address: 0x17B0
-# LLVM_NONRELOC-NEXT:       Version: 0
-# LLVM_NONRELOC-NEXT:       IsIndirectTarget: Yes
-# LLVM_NONRELOC-NEXT:       TypeId: 0x308E4B8159BC8654
-# LLVM_NONRELOC-NEXT:       NumDirectCallees: 0
-# LLVM_NONRELOC-NEXT:       DirectCallees [
-# LLVM_NONRELOC-NEXT:       ]
-# LLVM_NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
-# LLVM_NONRELOC-NEXT:       IndirectTypeIDs: []
-# LLVM_NONRELOC-NEXT:     }
-# LLVM_NONRELOC-NEXT:     Function {
-# LLVM_NONRELOC-NEXT:       Names: [main]
-# LLVM_NONRELOC-NEXT:       Address: 0x17C0
-# LLVM_NONRELOC-NEXT:       Version: 0
-# LLVM_NONRELOC-NEXT:       IsIndirectTarget: Yes
-# LLVM_NONRELOC-NEXT:       TypeId: 0xFA6809609A76AFCA
-# LLVM_NONRELOC-NEXT:       NumDirectCallees: 3
-# LLVM_NONRELOC-NEXT:       DirectCallees [
-# LLVM_NONRELOC-NEXT:         {
-# LLVM_NONRELOC-NEXT:           Names: [foo]
-# LLVM_NONRELOC-NEXT:           Address: 0x1790
-# LLVM_NONRELOC-NEXT:         }
-# LLVM_NONRELOC-NEXT:         {
-# LLVM_NONRELOC-NEXT:           Names: [bar]
-# LLVM_NONRELOC-NEXT:           Address: 0x17A0
-# LLVM_NONRELOC-NEXT:         }
-# LLVM_NONRELOC-NEXT:         {
-# LLVM_NONRELOC-NEXT:           Names: [baz]
-# LLVM_NONRELOC-NEXT:           Address: 0x17B0
-# LLVM_NONRELOC-NEXT:         }
-# LLVM_NONRELOC-NEXT:       ]
-# LLVM_NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 2
-# LLVM_NONRELOC-NEXT:       IndirectTypeIDs: [0x3ECBEEF531F74424, 0x308E4B8159BC8654]
-# LLVM_NONRELOC-NEXT:     }
-# LLVM_NONRELOC-NEXT:   ]
-
-# JSON_NONRELOC:     "CallGraph": [
-# JSON_NONRELOC-NEXT:      {
-# JSON_NONRELOC-NEXT:        "Function": {
-# JSON_NONRELOC-NEXT:          "Names": [
-# JSON_NONRELOC-NEXT:            "foo"
-# JSON_NONRELOC-NEXT:          ],
-# JSON_NONRELOC-NEXT:          "Address": 6032,
-# JSON_NONRELOC-NEXT:          "Version": 0,
-# JSON_NONRELOC-NEXT:          "IsIndirectTarget": true,
-# JSON_NONRELOC-NEXT:          "TypeId": 4524972987496481828,
-# JSON_NONRELOC-NEXT:          "NumDirectCallees": 0,
-# JSON_NONRELOC-NEXT:          "DirectCallees": [],
-# JSON_NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON_NONRELOC-NEXT:          "IndirectTypeIDs": []
-# JSON_NONRELOC-NEXT:        }
-# JSON_NONRELOC-NEXT:      },
-# JSON_NONRELOC-NEXT:      {
-# JSON_NONRELOC-NEXT:        "Function": {
-# JSON_NONRELOC-NEXT:          "Names": [
-# JSON_NONRELOC-NEXT:            "bar"
-# JSON_NONRELOC-NEXT:          ],
-# JSON_NONRELOC-NEXT:          "Address": 6048,
-# JSON_NONRELOC-NEXT:          "Version": 0,
-# JSON_NONRELOC-NEXT:          "IsIndirectTarget": true,
-# JSON_NONRELOC-NEXT:          "TypeId": 4524972987496481828,
-# JSON_NONRELOC-NEXT:          "NumDirectCallees": 0,
-# JSON_NONRELOC-NEXT:          "DirectCallees": [],
-# JSON_NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON_NONRELOC-NEXT:          "IndirectTypeIDs": []
-# JSON_NONRELOC-NEXT:        }
-# JSON_NONRELOC-NEXT:      },
-# JSON_NONRELOC-NEXT:      {
-# JSON_NONRELOC-NEXT:        "Function": {
-# JSON_NONRELOC-NEXT:          "Names": [
-# JSON_NONRELOC-NEXT:            "baz"
-# JSON_NONRELOC-NEXT:          ],
-# JSON_NONRELOC-NEXT:          "Address": 6064,
-# JSON_NONRELOC-NEXT:          "Version": 0,
-# JSON_NONRELOC-NEXT:          "IsIndirectTarget": true,
-# JSON_NONRELOC-NEXT:          "TypeId": 3498816979441845844,
-# JSON_NONRELOC-NEXT:          "NumDirectCallees": 0,
-# JSON_NONRELOC-NEXT:          "DirectCallees": [],
-# JSON_NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON_NONRELOC-NEXT:          "IndirectTypeIDs": []
-# JSON_NONRELOC-NEXT:        }
-# JSON_NONRELOC-NEXT:      },
-# JSON_NONRELOC-NEXT:      {
-# JSON_NONRELOC-NEXT:        "Function": {
-# JSON_NONRELOC-NEXT:          "Names": [
-# JSON_NONRELOC-NEXT:            "main"
-# JSON_NONRELOC-NEXT:          ],
-# JSON_NONRELOC-NEXT:          "Address": 6080,
-# JSON_NONRELOC-NEXT:          "Version": 0,
-# JSON_NONRELOC-NEXT:          "IsIndirectTarget": true,
-# JSON_NONRELOC-NEXT:          "TypeId": 18043682217572872138,
-# JSON_NONRELOC-NEXT:          "NumDirectCallees": 3,
-# JSON_NONRELOC-NEXT:          "DirectCallees": [
-# JSON_NONRELOC-NEXT:            {
-# JSON_NONRELOC-NEXT:              "Names": [
-# JSON_NONRELOC-NEXT:                "foo"
-# JSON_NONRELOC-NEXT:              ],
-# JSON_NONRELOC-NEXT:              "Address": 6032
-# JSON_NONRELOC-NEXT:            },
-# JSON_NONRELOC-NEXT:            {
-# JSON_NONRELOC-NEXT:              "Names": [
-# JSON_NONRELOC-NEXT:                "bar"
-# JSON_NONRELOC-NEXT:              ],
-# JSON_NONRELOC-NEXT:              "Address": 6048
-# JSON_NONRELOC-NEXT:            },
-# JSON_NONRELOC-NEXT:            {
-# JSON_NONRELOC-NEXT:              "Names": [
-# JSON_NONRELOC-NEXT:                "baz"
-# JSON_NONRELOC-NEXT:              ],
-# JSON_NONRELOC-NEXT:              "Address": 6064
-# JSON_NONRELOC-NEXT:            }
-# JSON_NONRELOC-NEXT:          ],
-# JSON_NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 2,
-# JSON_NONRELOC-NEXT:          "IndirectTypeIDs": [
-# JSON_NONRELOC-NEXT:            4524972987496481828,
-# JSON_NONRELOC-NEXT:            3498816979441845844
-# JSON_NONRELOC-NEXT:          ]
-# JSON_NONRELOC-NEXT:        }
-# JSON_NONRELOC-NEXT:      }
-# JSON_NONRELOC-NEXT:    ]
+# JSON-NONRELOC:     "CallGraph": [
+# JSON-NONRELOC-NEXT:      {
+# JSON-NONRELOC-NEXT:        "Function": {
+# JSON-NONRELOC-NEXT:          "Names": [
+# JSON-NONRELOC-NEXT:            "foo"
+# JSON-NONRELOC-NEXT:          ],
+# JSON-NONRELOC-NEXT:          "Address": 6032,
+# JSON-NONRELOC-NEXT:          "Version": 0,
+# JSON-NONRELOC-NEXT:          "IsIndirectTarget": true,
+# JSON-NONRELOC-NEXT:          "TypeId": 4524972987496481828,
+# JSON-NONRELOC-NEXT:          "NumDirectCallees": 0,
+# JSON-NONRELOC-NEXT:          "DirectCallees": [],
+# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-NONRELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-NONRELOC-NEXT:        }
+# JSON-NONRELOC-NEXT:      },
+# JSON-NONRELOC-NEXT:      {
+# JSON-NONRELOC-NEXT:        "Function": {
+# JSON-NONRELOC-NEXT:          "Names": [
+# JSON-NONRELOC-NEXT:            "bar"
+# JSON-NONRELOC-NEXT:          ],
+# JSON-NONRELOC-NEXT:          "Address": 6048,
+# JSON-NONRELOC-NEXT:          "Version": 0,
+# JSON-NONRELOC-NEXT:          "IsIndirectTarget": true,
+# JSON-NONRELOC-NEXT:          "TypeId": 4524972987496481828,
+# JSON-NONRELOC-NEXT:          "NumDirectCallees": 0,
+# JSON-NONRELOC-NEXT:          "DirectCallees": [],
+# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-NONRELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-NONRELOC-NEXT:        }
+# JSON-NONRELOC-NEXT:      },
+# JSON-NONRELOC-NEXT:      {
+# JSON-NONRELOC-NEXT:        "Function": {
+# JSON-NONRELOC-NEXT:          "Names": [
+# JSON-NONRELOC-NEXT:            "baz"
+# JSON-NONRELOC-NEXT:          ],
+# JSON-NONRELOC-NEXT:          "Address": 6064,
+# JSON-NONRELOC-NEXT:          "Version": 0,
+# JSON-NONRELOC-NEXT:          "IsIndirectTarget": true,
+# JSON-NONRELOC-NEXT:          "TypeId": 3498816979441845844,
+# JSON-NONRELOC-NEXT:          "NumDirectCallees": 0,
+# JSON-NONRELOC-NEXT:          "DirectCallees": [],
+# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-NONRELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-NONRELOC-NEXT:        }
+# JSON-NONRELOC-NEXT:      },
+# JSON-NONRELOC-NEXT:      {
+# JSON-NONRELOC-NEXT:        "Function": {
+# JSON-NONRELOC-NEXT:          "Names": [
+# JSON-NONRELOC-NEXT:            "main"
+# JSON-NONRELOC-NEXT:          ],
+# JSON-NONRELOC-NEXT:          "Address": 6080,
+# JSON-NONRELOC-NEXT:          "Version": 0,
+# JSON-NONRELOC-NEXT:          "IsIndirectTarget": true,
+# JSON-NONRELOC-NEXT:          "TypeId": 18043682217572872138,
+# JSON-NONRELOC-NEXT:          "NumDirectCallees": 3,
+# JSON-NONRELOC-NEXT:          "DirectCallees": [
+# JSON-NONRELOC-NEXT:            {
+# JSON-NONRELOC-NEXT:              "Names": [
+# JSON-NONRELOC-NEXT:                "foo"
+# JSON-NONRELOC-NEXT:              ],
+# JSON-NONRELOC-NEXT:              "Address": 6032
+# JSON-NONRELOC-NEXT:            },
+# JSON-NONRELOC-NEXT:            {
+# JSON-NONRELOC-NEXT:              "Names": [
+# JSON-NONRELOC-NEXT:                "bar"
+# JSON-NONRELOC-NEXT:              ],
+# JSON-NONRELOC-NEXT:              "Address": 6048
+# JSON-NONRELOC-NEXT:            },
+# JSON-NONRELOC-NEXT:            {
+# JSON-NONRELOC-NEXT:              "Names": [
+# JSON-NONRELOC-NEXT:                "baz"
+# JSON-NONRELOC-NEXT:              ],
+# JSON-NONRELOC-NEXT:              "Address": 6064
+# JSON-NONRELOC-NEXT:            }
+# JSON-NONRELOC-NEXT:          ],
+# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 2,
+# JSON-NONRELOC-NEXT:          "IndirectTypeIDs": [
+# JSON-NONRELOC-NEXT:            4524972987496481828,
+# JSON-NONRELOC-NEXT:            3498816979441845844
+# JSON-NONRELOC-NEXT:          ]
+# JSON-NONRELOC-NEXT:        }
+# JSON-NONRELOC-NEXT:      }
+# JSON-NONRELOC-NEXT:    ]
 
 --- !ELF
 FileHeader:
@@ -233,132 +230,129 @@ Symbols:
 # RUN: yaml2obj --docnum=2 %s -o %t2
 # RUN: llvm-readobj --elf-output-style=GNU --call-graph-info %t2 2>&1 | count 0
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t2 2>&1 | \
-# RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM_RELOC -DFILE=%t2
+# RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM-RELOC -DFILE=%t2
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t2 2>&1 | \
-# RUN:   FileCheck %s --match-full-lines --check-prefix=JSON_RELOC -DFILE=%t2
-
-## We do not support GNU format console output for --call-graph-info as it is an LLVM only info.
-# GNU_RELOC-NOT: .
+# RUN:   FileCheck %s --match-full-lines --check-prefix=JSON-RELOC -DFILE=%t2
 
-# LLVM_RELOC:   CallGraph [
-# LLVM_RELOC-NEXT:   Function {
-# LLVM_RELOC-NEXT:     Name: foo
-# LLVM_RELOC-NEXT:     Version: 0
-# LLVM_RELOC-NEXT:     IsIndirectTarget: Yes
-# LLVM_RELOC-NEXT:     TypeId: 0xF85C699BB8EF20A2
-# LLVM_RELOC-NEXT:     NumDirectCallees: 0
-# LLVM_RELOC-NEXT:     DirectCallees [
-# LLVM_RELOC-NEXT:     ]
-# LLVM_RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
-# LLVM_RELOC-NEXT:     IndirectTypeIDs: []
-# LLVM_RELOC-NEXT:   }
-# LLVM_RELOC-NEXT:   Function {
-# LLVM_RELOC-NEXT:     Name: bar
-# LLVM_RELOC-NEXT:     Version: 0
-# LLVM_RELOC-NEXT:     IsIndirectTarget: Yes
-# LLVM_RELOC-NEXT:     TypeId: 0xF85C699BB8EF20A2
-# LLVM_RELOC-NEXT:     NumDirectCallees: 0
-# LLVM_RELOC-NEXT:     DirectCallees [
-# LLVM_RELOC-NEXT:     ]
-# LLVM_RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
-# LLVM_RELOC-NEXT:     IndirectTypeIDs: []
-# LLVM_RELOC-NEXT:   }
-# LLVM_RELOC-NEXT:   Function {
-# LLVM_RELOC-NEXT:     Name: baz
-# LLVM_RELOC-NEXT:     Version: 0
-# LLVM_RELOC-NEXT:     IsIndirectTarget: Yes
-# LLVM_RELOC-NEXT:     TypeId: 0x308E4B8159BC8654
-# LLVM_RELOC-NEXT:     NumDirectCallees: 0
-# LLVM_RELOC-NEXT:     DirectCallees [
-# LLVM_RELOC-NEXT:     ]
-# LLVM_RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
-# LLVM_RELOC-NEXT:     IndirectTypeIDs: []
-# LLVM_RELOC-NEXT:   }
-# LLVM_RELOC-NEXT:   Function {
-# LLVM_RELOC-NEXT:     Name: caller
-# LLVM_RELOC-NEXT:     Version: 0
-# LLVM_RELOC-NEXT:     IsIndirectTarget: Yes
-# LLVM_RELOC-NEXT:     TypeId: 0xA9494DEF81A01DC
-# LLVM_RELOC-NEXT:     NumDirectCallees: 3
-# LLVM_RELOC-NEXT:     DirectCallees [
-# LLVM_RELOC-NEXT:       {
-# LLVM_RELOC-NEXT:         Name: foo
-# LLVM_RELOC-NEXT:       }
-# LLVM_RELOC-NEXT:       {
-# LLVM_RELOC-NEXT:         Name: bar
-# LLVM_RELOC-NEXT:       }
-# LLVM_RELOC-NEXT:       {
-# LLVM_RELOC-NEXT:         Name: baz
-# LLVM_RELOC-NEXT:       }
-# LLVM_RELOC-NEXT:     ]
-# LLVM_RELOC-NEXT:     NumIndirectTargetTypeIDs: 2
-# LLVM_RELOC-NEXT:     IndirectTypeIDs: [0xF85C699BB8EF20A2, 0x308E4B8159BC8654]
-# LLVM_RELOC-NEXT:   }
-# LLVM_RELOC-NEXT: ]
+# LLVM-RELOC:   CallGraph [
+# LLVM-RELOC-NEXT:   Function {
+# LLVM-RELOC-NEXT:     Name: foo
+# LLVM-RELOC-NEXT:     Version: 0
+# LLVM-RELOC-NEXT:     IsIndirectTarget: Yes
+# LLVM-RELOC-NEXT:     TypeId: 0xF85C699BB8EF20A2
+# LLVM-RELOC-NEXT:     NumDirectCallees: 0
+# LLVM-RELOC-NEXT:     DirectCallees [
+# LLVM-RELOC-NEXT:     ]
+# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM-RELOC-NEXT:     IndirectTypeIDs: []
+# LLVM-RELOC-NEXT:   }
+# LLVM-RELOC-NEXT:   Function {
+# LLVM-RELOC-NEXT:     Name: bar
+# LLVM-RELOC-NEXT:     Version: 0
+# LLVM-RELOC-NEXT:     IsIndirectTarget: Yes
+# LLVM-RELOC-NEXT:     TypeId: 0xF85C699BB8EF20A2
+# LLVM-RELOC-NEXT:     NumDirectCallees: 0
+# LLVM-RELOC-NEXT:     DirectCallees [
+# LLVM-RELOC-NEXT:     ]
+# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM-RELOC-NEXT:     IndirectTypeIDs: []
+# LLVM-RELOC-NEXT:   }
+# LLVM-RELOC-NEXT:   Function {
+# LLVM-RELOC-NEXT:     Name: baz
+# LLVM-RELOC-NEXT:     Version: 0
+# LLVM-RELOC-NEXT:     IsIndirectTarget: Yes
+# LLVM-RELOC-NEXT:     TypeId: 0x308E4B8159BC8654
+# LLVM-RELOC-NEXT:     NumDirectCallees: 0
+# LLVM-RELOC-NEXT:     DirectCallees [
+# LLVM-RELOC-NEXT:     ]
+# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM-RELOC-NEXT:     IndirectTypeIDs: []
+# LLVM-RELOC-NEXT:   }
+# LLVM-RELOC-NEXT:   Function {
+# LLVM-RELOC-NEXT:     Name: caller
+# LLVM-RELOC-NEXT:     Version: 0
+# LLVM-RELOC-NEXT:     IsIndirectTarget: Yes
+# LLVM-RELOC-NEXT:     TypeId: 0xA9494DEF81A01DC
+# LLVM-RELOC-NEXT:     NumDirectCallees: 3
+# LLVM-RELOC-NEXT:     DirectCallees [
+# LLVM-RELOC-NEXT:       {
+# LLVM-RELOC-NEXT:         Name: foo
+# LLVM-RELOC-NEXT:       }
+# LLVM-RELOC-NEXT:       {
+# LLVM-RELOC-NEXT:         Name: bar
+# LLVM-RELOC-NEXT:       }
+# LLVM-RELOC-NEXT:       {
+# LLVM-RELOC-NEXT:         Name: baz
+# LLVM-RELOC-NEXT:       }
+# LLVM-RELOC-NEXT:     ]
+# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 2
+# LLVM-RELOC-NEXT:     IndirectTypeIDs: [0xF85C699BB8EF20A2, 0x308E4B8159BC8654]
+# LLVM-RELOC-NEXT:   }
+# LLVM-RELOC-NEXT: ]
 
-# JSON_RELOC:     "CallGraph": [
-# JSON_RELOC-NEXT:      {
-# JSON_RELOC-NEXT:        "Function": {
-# JSON_RELOC-NEXT:          "Name": "foo",
-# JSON_RELOC-NEXT:          "Version": 0,
-# JSON_RELOC-NEXT:          "IsIndirectTarget": true,
-# JSON_RELOC-NEXT:          "TypeId": 17896295136807035042,
-# JSON_RELOC-NEXT:          "NumDirectCallees": 0,
-# JSON_RELOC-NEXT:          "DirectCallees": [],
-# JSON_RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON_RELOC-NEXT:          "IndirectTypeIDs": []
-# JSON_RELOC-NEXT:        }
-# JSON_RELOC-NEXT:      },
-# JSON_RELOC-NEXT:      {
-# JSON_RELOC-NEXT:        "Function": {
-# JSON_RELOC-NEXT:          "Name": "bar",
-# JSON_RELOC-NEXT:          "Version": 0,
-# JSON_RELOC-NEXT:          "IsIndirectTarget": true,
-# JSON_RELOC-NEXT:          "TypeId": 17896295136807035042,
-# JSON_RELOC-NEXT:          "NumDirectCallees": 0,
-# JSON_RELOC-NEXT:          "DirectCallees": [],
-# JSON_RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON_RELOC-NEXT:          "IndirectTypeIDs": []
-# JSON_RELOC-NEXT:        }
-# JSON_RELOC-NEXT:      },
-# JSON_RELOC-NEXT:      {
-# JSON_RELOC-NEXT:        "Function": {
-# JSON_RELOC-NEXT:          "Name": "baz",
-# JSON_RELOC-NEXT:          "Version": 0,
-# JSON_RELOC-NEXT:          "IsIndirectTarget": true,
-# JSON_RELOC-NEXT:          "TypeId": 3498816979441845844,
-# JSON_RELOC-NEXT:          "NumDirectCallees": 0,
-# JSON_RELOC-NEXT:          "DirectCallees": [],
-# JSON_RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON_RELOC-NEXT:          "IndirectTypeIDs": []
-# JSON_RELOC-NEXT:        }
-# JSON_RELOC-NEXT:      },
-# JSON_RELOC-NEXT:      {
-# JSON_RELOC-NEXT:        "Function": {
-# JSON_RELOC-NEXT:          "Name": "caller",
-# JSON_RELOC-NEXT:          "Version": 0,
-# JSON_RELOC-NEXT:          "IsIndirectTarget": true,
-# JSON_RELOC-NEXT:          "TypeId": 762397922298560988,
-# JSON_RELOC-NEXT:          "NumDirectCallees": 3,
-# JSON_RELOC-NEXT:          "DirectCallees": [
-# JSON_RELOC-NEXT:            {
-# JSON_RELOC-NEXT:              "Name": "foo"
-# JSON_RELOC-NEXT:            },
-# JSON_RELOC-NEXT:            {
-# JSON_RELOC-NEXT:              "Name": "bar"
-# JSON_RELOC-NEXT:            },
-# JSON_RELOC-NEXT:            {
-# JSON_RELOC-NEXT:              "Name": "baz"
-# JSON_RELOC-NEXT:            }
-# JSON_RELOC-NEXT:          ],
-# JSON_RELOC-NEXT:          "NumIndirectTargetTypeIDs": 2,
-# JSON_RELOC-NEXT:          "IndirectTypeIDs": [
-# JSON_RELOC-NEXT:            17896295136807035042,
-# JSON_RELOC-NEXT:            3498816979441845844
-# JSON_RELOC-NEXT:          ]
-# JSON_RELOC-NEXT:        }
-# JSON_RELOC-NEXT:      }
-# JSON_RELOC-NEXT:    ]
+# JSON-RELOC:     "CallGraph": [
+# JSON-RELOC-NEXT:      {
+# JSON-RELOC-NEXT:        "Function": {
+# JSON-RELOC-NEXT:          "Name": "foo",
+# JSON-RELOC-NEXT:          "Version": 0,
+# JSON-RELOC-NEXT:          "IsIndirectTarget": true,
+# JSON-RELOC-NEXT:          "TypeId": 17896295136807035042,
+# JSON-RELOC-NEXT:          "NumDirectCallees": 0,
+# JSON-RELOC-NEXT:          "DirectCallees": [],
+# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-RELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-RELOC-NEXT:        }
+# JSON-RELOC-NEXT:      },
+# JSON-RELOC-NEXT:      {
+# JSON-RELOC-NEXT:        "Function": {
+# JSON-RELOC-NEXT:          "Name": "bar",
+# JSON-RELOC-NEXT:          "Version": 0,
+# JSON-RELOC-NEXT:          "IsIndirectTarget": true,
+# JSON-RELOC-NEXT:          "TypeId": 17896295136807035042,
+# JSON-RELOC-NEXT:          "NumDirectCallees": 0,
+# JSON-RELOC-NEXT:          "DirectCallees": [],
+# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-RELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-RELOC-NEXT:        }
+# JSON-RELOC-NEXT:      },
+# JSON-RELOC-NEXT:      {
+# JSON-RELOC-NEXT:        "Function": {
+# JSON-RELOC-NEXT:          "Name": "baz",
+# JSON-RELOC-NEXT:          "Version": 0,
+# JSON-RELOC-NEXT:          "IsIndirectTarget": true,
+# JSON-RELOC-NEXT:          "TypeId": 3498816979441845844,
+# JSON-RELOC-NEXT:          "NumDirectCallees": 0,
+# JSON-RELOC-NEXT:          "DirectCallees": [],
+# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-RELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-RELOC-NEXT:        }
+# JSON-RELOC-NEXT:      },
+# JSON-RELOC-NEXT:      {
+# JSON-RELOC-NEXT:        "Function": {
+# JSON-RELOC-NEXT:          "Name": "caller",
+# JSON-RELOC-NEXT:          "Version": 0,
+# JSON-RELOC-NEXT:          "IsIndirectTarget": true,
+# JSON-RELOC-NEXT:          "TypeId": 762397922298560988,
+# JSON-RELOC-NEXT:          "NumDirectCallees": 3,
+# JSON-RELOC-NEXT:          "DirectCallees": [
+# JSON-RELOC-NEXT:            {
+# JSON-RELOC-NEXT:              "Name": "foo"
+# JSON-RELOC-NEXT:            },
+# JSON-RELOC-NEXT:            {
+# JSON-RELOC-NEXT:              "Name": "bar"
+# JSON-RELOC-NEXT:            },
+# JSON-RELOC-NEXT:            {
+# JSON-RELOC-NEXT:              "Name": "baz"
+# JSON-RELOC-NEXT:            }
+# JSON-RELOC-NEXT:          ],
+# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 2,
+# JSON-RELOC-NEXT:          "IndirectTypeIDs": [
+# JSON-RELOC-NEXT:            17896295136807035042,
+# JSON-RELOC-NEXT:            3498816979441845844
+# JSON-RELOC-NEXT:          ]
+# JSON-RELOC-NEXT:        }
+# JSON-RELOC-NEXT:      }
+# JSON-RELOC-NEXT:    ]
 
 --- !ELF
 FileHeader:
@@ -457,38 +451,38 @@ Symbols:
 ## Check ARM 32-bit Thumb address handling.
 # RUN: yaml2obj --docnum=3 %s -o %t3
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t3 2>&1 | \
-# RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM_ARM_THUMB -DFILE=%t3
+# RUN:   FileCheck %s --match-full-lines --check-prefix=LLVM-ARM-THUMB -DFILE=%t3
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t3 2>&1 | \
-# RUN:   FileCheck %s --match-full-lines --check-prefix=JSON_ARM_THUMB -DFILE=%t3
+# RUN:   FileCheck %s --match-full-lines --check-prefix=JSON-ARM-THUMB -DFILE=%t3
 
-# LLVM_ARM_THUMB:      CallGraph [
-# LLVM_ARM_THUMB-NEXT:   Function {
-# LLVM_ARM_THUMB-NEXT:     Name: foo
-# LLVM_ARM_THUMB-NEXT:     Version: 0
-# LLVM_ARM_THUMB-NEXT:     IsIndirectTarget: No
-# LLVM_ARM_THUMB-NEXT:     TypeId: 0x123456789ABCDEF0
-# LLVM_ARM_THUMB-NEXT:     NumDirectCallees: 0
-# LLVM_ARM_THUMB-NEXT:     DirectCallees [
-# LLVM_ARM_THUMB-NEXT:     ]
-# LLVM_ARM_THUMB-NEXT:     NumIndirectTargetTypeIDs: 0
-# LLVM_ARM_THUMB-NEXT:     IndirectTypeIDs: []
-# LLVM_ARM_THUMB-NEXT:   }
-# LLVM_ARM_THUMB-NEXT: ]
+# LLVM-ARM-THUMB:      CallGraph [
+# LLVM-ARM-THUMB-NEXT:   Function {
+# LLVM-ARM-THUMB-NEXT:     Name: foo
+# LLVM-ARM-THUMB-NEXT:     Version: 0
+# LLVM-ARM-THUMB-NEXT:     IsIndirectTarget: No
+# LLVM-ARM-THUMB-NEXT:     TypeId: 0x123456789ABCDEF0
+# LLVM-ARM-THUMB-NEXT:     NumDirectCallees: 0
+# LLVM-ARM-THUMB-NEXT:     DirectCallees [
+# LLVM-ARM-THUMB-NEXT:     ]
+# LLVM-ARM-THUMB-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM-ARM-THUMB-NEXT:     IndirectTypeIDs: []
+# LLVM-ARM-THUMB-NEXT:   }
+# LLVM-ARM-THUMB-NEXT: ]
 
-# JSON_ARM_THUMB:       "CallGraph": [
-# JSON_ARM_THUMB-NEXT:    {
-# JSON_ARM_THUMB-NEXT:      "Function": {
-# JSON_ARM_THUMB-NEXT:        "Name": "foo",
-# JSON_ARM_THUMB-NEXT:        "Version": 0,
-# JSON_ARM_THUMB-NEXT:        "IsIndirectTarget": false,
-# JSON_ARM_THUMB-NEXT:        "TypeId": 1311768467463790320,
-# JSON_ARM_THUMB-NEXT:        "NumDirectCallees": 0,
-# JSON_ARM_THUMB-NEXT:        "DirectCallees": [],
-# JSON_ARM_THUMB-NEXT:        "NumIndirectTargetTypeIDs": 0,
-# JSON_ARM_THUMB-NEXT:        "IndirectTypeIDs": []
-# JSON_ARM_THUMB-NEXT:      }
-# JSON_ARM_THUMB-NEXT:    }
-# JSON_ARM_THUMB-NEXT:  ]
+# JSON-ARM-THUMB:       "CallGraph": [
+# JSON-ARM-THUMB-NEXT:    {
+# JSON-ARM-THUMB-NEXT:      "Function": {
+# JSON-ARM-THUMB-NEXT:        "Name": "foo",
+# JSON-ARM-THUMB-NEXT:        "Version": 0,
+# JSON-ARM-THUMB-NEXT:        "IsIndirectTarget": false,
+# JSON-ARM-THUMB-NEXT:        "TypeId": 1311768467463790320,
+# JSON-ARM-THUMB-NEXT:        "NumDirectCallees": 0,
+# JSON-ARM-THUMB-NEXT:        "DirectCallees": [],
+# JSON-ARM-THUMB-NEXT:        "NumIndirectTargetTypeIDs": 0,
+# JSON-ARM-THUMB-NEXT:        "IndirectTypeIDs": []
+# JSON-ARM-THUMB-NEXT:      }
+# JSON-ARM-THUMB-NEXT:    }
+# JSON-ARM-THUMB-NEXT:  ]
 
 --- !ELF
 FileHeader:
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 7239230704678..894d67ef9e4ee 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5485,7 +5485,7 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
   if (UnknownCount)
     reportUniqueWarning(
         "SHT_LLVM_CALL_GRAPH type section has unknown type id for " +
-        std::to_string(UnknownCount) + " indirect targets");
+        Twine(UnknownCount) + " indirect targets");
   return true;
 }
 

>From 92a0645e6e876fb62690cc3267e6faebcb2218d6 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Jan 2026 00:18:23 +0000
Subject: [PATCH 05/22] Remove Machine from non rela tests.

---
 .../ELF/call-graph-info-warn-malformed.test            | 10 ----------
 llvm/test/tools/llvm-readobj/ELF/call-graph-info.test  |  1 -
 2 files changed, 11 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index 960b49ef0faf2..5dc32fe7461fa 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -16,7 +16,6 @@ FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
   Type:     ET_DYN
-  Machine:  EM_X86_64
 ...
 
 ## Check format version number.
@@ -33,7 +32,6 @@ FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
   Type:     ET_DYN
-  Machine:  EM_X86_64
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
@@ -62,7 +60,6 @@ FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
   Type:     ET_DYN
-  Machine:  EM_X86_64
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
@@ -92,7 +89,6 @@ FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
   Type:     ET_DYN
-  Machine:  EM_X86_64
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
@@ -122,7 +118,6 @@ FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
   Type:     ET_DYN
-  Machine:  EM_X86_64
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
@@ -153,7 +148,6 @@ FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
   Type:     ET_DYN
-  Machine:  EM_X86_64
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
@@ -185,7 +179,6 @@ FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
   Type:     ET_DYN
-  Machine:  EM_X86_64
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
@@ -218,7 +211,6 @@ FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
   Type:     ET_DYN
-  Machine:  EM_X86_64
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
@@ -252,7 +244,6 @@ FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
   Type:     ET_DYN
-  Machine:  EM_X86_64
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
@@ -285,7 +276,6 @@ FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
   Type:     ET_REL
-  Machine:  EM_X86_64
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
index cb60ec760de58..cda1f8aa0586b 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
@@ -161,7 +161,6 @@ FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
   Type:     ET_DYN
-  Machine:  EM_X86_64
 Sections:
   - Name:   .text
     Type:   SHT_PROGBITS

>From b2f05bbee34b7464b8d2d2214fbfbc327c4ce1e9 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Jan 2026 00:42:03 +0000
Subject: [PATCH 06/22] Make inline non command comments ##

---
 .../ELF/call-graph-info-warn-malformed.test   | 118 +++++++-------
 .../llvm-readobj/ELF/call-graph-info.test     | 150 +++++++++---------
 2 files changed, 134 insertions(+), 134 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index 5dc32fe7461fa..3847ba7a1af49 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -39,8 +39,8 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      # --- Entry 1: foo (foo) ---
-      0x01, # Format Version - only supported value is 0x00
+      ## --- Entry 1: foo (foo) ---
+      0x01, ## Format Version - only supported value is 0x00
     ]
 Symbols:
   - Name:  foo
@@ -67,9 +67,9 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      # --- Entry 1: foo (foo) ---
-      0x00, # Format Version
-      #< Missing flags
+      ## --- Entry 1: foo (foo) ---
+      0x00, ## Format Version
+      ##<Missing flags
     ]
 Symbols:
   - Name:  foo
@@ -96,9 +96,9 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      # --- Entry 1: foo (foo) ---
-      0x00, # Format Version
-      0x08, # Flags - only valid values are 0x00 to 0x07
+      ## --- Entry 1: foo (foo) ---
+      0x00, ## Format Version
+      0x08, ## Flags - only valid values are 0x00 to 0x07
     ]
 Symbols:
   - Name:  foo
@@ -125,10 +125,10 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      # --- Entry 1: foo (foo) ---
-      0x00, # Format Version
-      0x00, # Flags
-      #< Missing function entry PC
+      ## --- Entry 1: foo (foo) ---
+      0x00, ## Format Version
+      0x00, ## Flags
+      ##<Missing function entry PC
     ]
 Symbols:
   - Name:  foo
@@ -155,11 +155,11 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      # --- Entry 1: foo (foo) ---
-      0x00, # Format Version
-      0x00, # Flags
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Function entry address
-      #< Missing Type ID
+      ## --- Entry 1: foo (foo) ---
+      0x00, ## Format Version
+      0x00, ## Flags
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
+      ##<Missing Type ID
     ]
 Symbols:
   - Name:  foo
@@ -186,12 +186,12 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      # --- Entry 1: foo (foo) ---
-      0x00, # Format Version
-      0x02, # Flags (HasDirectCallees)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Function entry address
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # TypeID unknown
-      #< Missing NumDirectCallees (ULEB128)
+      ## --- Entry 1: foo (foo) ---
+      0x00, ## Format Version
+      0x02, ## Flags (HasDirectCallees)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## TypeID unknown
+      ##<Missing NumDirectCallees (ULEB128)
     ]
 Symbols:
   - Name:  foo
@@ -218,13 +218,13 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      # --- Entry 1: foo (foo) ---
-      0x00, # Format Version
-      0x02, # Flags (HasDirectCallees)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Function entry address
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # TypeID unknown
-      0x01, # NumDirectCallees
-      #< Missing direct callee address
+      ## --- Entry 1: foo (foo) ---
+      0x00, ## Format Version
+      0x02, ## Flags (HasDirectCallees)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## TypeID unknown
+      0x01, ## NumDirectCallees
+      ##<Missing direct callee address
     ]
 Symbols:
   - Name:  foo
@@ -251,12 +251,12 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      # --- Entry 1: foo (foo) ---
-      0x00, # Format Version
-      0x04, # Flags (HasIndirectCallees)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Function entry address
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # TypeID unknown
-      #< Missing NumIndirectTargetTypeIDs (ULEB128)
+      ## --- Entry 1: foo (foo) ---
+      0x00, ## Format Version
+      0x04, ## Flags (HasIndirectCallees)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## TypeID unknown
+      ##<Missing NumIndirectTargetTypeIDs (ULEB128)
     ]
 Symbols:
   - Name:  foo
@@ -283,13 +283,13 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      # --- Entry 1: foo (foo) ---
-      0x00, # Format Version
-      0x04, # Flags (HasIndirectCallees)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Function entry address
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # TypeID unknown
-      0x01, # NumIndirectTargetTypeIDs (1)
-      #< Missing indirect call entries here.
+      ## --- Entry 1: foo (foo) ---
+      0x00, ## Format Version
+      0x04, ## Flags (HasIndirectCallees)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## TypeID unknown
+      0x01, ## NumIndirectTargetTypeIDs (1)
+      ##<Missing indirect call entries here.
     ]
 Symbols:
   - Name:  foo
@@ -322,22 +322,22 @@ Sections:
   - Name: .llvm.callgraph
     Type: SHT_LLVM_CALL_GRAPH
     ContentArray: [
-        '0', # Format version number
-        '3', # Flag IsIndirectTarget true, HasDirectCallees true
-        '0', '0', '0', '0', '0', '0', '0', '0', # foo()'s address
-        '0', '0', '0', '0', '0', '0', '0', '0', # foo()'s TypeID Unknown
-        '1', # NumDirectCallees
-        '0', '0', '0', '0', '0', '0', '0', '0', # Direct callee foo()'s address
-        '0', # Format version number
-        '5', # Flag IsIndirectTarget true, HasIndirectTargetTypeIDs true
-        '6', '0', '0', '0', '0', '0', '0', '0', # bar()'s address
-        '0', '0', '0', '0', '0', '0', '0', '0', # bar()'s TypeID Unknown
-        '1', # NumIndirectTargetTypeIDs
-        '16', '0', '0', '0', '0', '0', '0', '0', # Indirect callee type ID
-        '0', # Format version number
-        '1', # Flag IsIndirectTarget true
-        '10', '0', '0', '0', '0', '0', '0', '0', # baz()'s address
-        '32', '0', '0', '0', '0', '0', '0', '0', # baz()'s TypeID Unknown
+        '0', ## Format version number
+        '3', ## Flag IsIndirectTarget true, HasDirectCallees true
+        '0', '0', '0', '0', '0', '0', '0', '0', ## foo()'s address
+        '0', '0', '0', '0', '0', '0', '0', '0', ## foo()'s TypeID Unknown
+        '1', ## NumDirectCallees
+        '0', '0', '0', '0', '0', '0', '0', '0', ## Direct callee foo()'s address
+        '0', ## Format version number
+        '5', ## Flag IsIndirectTarget true, HasIndirectTargetTypeIDs true
+        '6', '0', '0', '0', '0', '0', '0', '0', ## bar()'s address
+        '0', '0', '0', '0', '0', '0', '0', '0', ## bar()'s TypeID Unknown
+        '1', ## NumIndirectTargetTypeIDs
+        '16', '0', '0', '0', '0', '0', '0', '0', ## Indirect callee type ID
+        '0', ## Format version number
+        '1', ## Flag IsIndirectTarget true
+        '10', '0', '0', '0', '0', '0', '0', '0', ## baz()'s address
+        '32', '0', '0', '0', '0', '0', '0', '0', ## baz()'s TypeID Unknown
       ]
   - Type:   SHT_RELA
     Relocations:
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
index cda1f8aa0586b..91e85c0ca4c42 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
@@ -171,40 +171,40 @@ Sections:
     Flags:  [ SHF_LINK_ORDER ]
     Link:   .text
     ContentArray: [
-      # --- foo ---
-      0x00, # Version
-      0x01, # Flags
-      0x90, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # FunctionEntryPC: 0x1790
-      0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, # FunctionTypeID: 0x3ECBEEF531F74424
+      ## --- foo ---
+      0x00, ## Version
+      0x01, ## Flags
+      0x90, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## FunctionEntryPC: 0x1790
+      0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, ## FunctionTypeID: 0x3ECBEEF531F74424
 
-      # --- bar ---
-      0x00, # Version
-      0x01, # Flags
-      0xA0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # FunctionEntryPC: 0x17A0
-      0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, # FunctionTypeID: 0x3ECBEEF531F74424
+      ## --- bar ---
+      0x00, ## Version
+      0x01, ## Flags
+      0xA0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## FunctionEntryPC: 0x17A0
+      0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, ## FunctionTypeID: 0x3ECBEEF531F74424
 
-      # --- baz ---
-      0x00, # Version
-      0x01, # Flags
-      0xB0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # FunctionEntryPC: 0x17B0
-      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30, # FunctionTypeID: 0x308E4B8159BC8654
+      ## --- baz ---
+      0x00, ## Version
+      0x01, ## Flags
+      0xB0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## FunctionEntryPC: 0x17B0
+      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30, ## FunctionTypeID: 0x308E4B8159BC8654
 
-      # --- main ---
-      0x00, # Version
-      0x07, # Flags
-      0xC0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # FunctionEntryPC: 0x17C0
-      0xCA, 0xAF, 0x76, 0x9A, 0x60, 0x09, 0x68, 0xFA, # FunctionTypeID: 0xFA6809609A76AFCA
+      ## --- main ---
+      0x00, ## Version
+      0x07, ## Flags
+      0xC0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## FunctionEntryPC: 0x17C0
+      0xCA, 0xAF, 0x76, 0x9A, 0x60, 0x09, 0x68, 0xFA, ## FunctionTypeID: 0xFA6809609A76AFCA
 
-      # Direct Callees
-      0x03, # NumDirectCallees
-      0x90, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 1: 0x1790 (foo)
-      0xA0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 2: 0x17A0 (bar)
-      0xB0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 3: 0x17B0 (baz)
+      ## Direct Callees
+      0x03, ## NumDirectCallees
+      0x90, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Callee 1: 0x1790 (foo)
+      0xA0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Callee 2: 0x17A0 (bar)
+      0xB0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Callee 3: 0x17B0 (baz)
 
-      # Indirect Callees
-      0x02, # NumIndirectTargetTypeIDs
-      0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, # TypeID 1
-      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30  # TypeID 2
+      ## Indirect Callees
+      0x02, ## NumIndirectTargetTypeIDs
+      0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, ## TypeID 1
+      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30  ## TypeID 2
     ]
 Symbols:
   - Name:     foo
@@ -368,51 +368,51 @@ Sections:
     Flags:  [ SHF_LINK_ORDER ]
     Link:   .text
     ContentArray: [
-      # --- Entry 1: foo (foo) ---
-      # Offset 0x0
-      0x00, # Format Version
-      0x01, # Flags
-      # Offset 0x2 (Matches Reloc: foo)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Address of foo
-      0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, # TypeID of foo
+      ## --- Entry 1: foo (foo) ---
+      ## Offset 0x0
+      0x00, ## Format Version
+      0x01, ## Flags
+      ## Offset 0x2 (Matches Reloc: foo)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Address of foo
+      0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, ## TypeID of foo
 
-      # --- Entry 2: bar (bar) ---
-      # Offset 0x12
-      0x00, # Format Version
-      0x01, # Flags
-      # Offset 0x14 (Matches Reloc: bar)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Address of bar
-      0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, # TypeID of bar
+      ## --- Entry 2: bar (bar) ---
+      ## Offset 0x12
+      0x00, ## Format Version
+      0x01, ## Flags
+      ## Offset 0x14 (Matches Reloc: bar)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Address of bar
+      0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, ## TypeID of bar
 
-      # --- Entry 3: baz (baz) ---
-      # Offset 0x24
-      0x00, # Format Version
-      0x01, # Flags
-      # Offset 0x26 (Matches Reloc: baz)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Address of baz
-      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30, # TypeID of baz
+      ## --- Entry 3: baz (baz) ---
+      ## Offset 0x24
+      0x00, ## Format Version
+      0x01, ## Flags
+      ## Offset 0x26 (Matches Reloc: baz)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Address of baz
+      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30, ## TypeID of baz
 
-      # --- Entry 4: caller (caller) ---
-      # Offset 0x36
-      0x00, # Format Version
-      0x07, # Flags (HasDirectCallees | IsIndirectTarget | ...)
-      # Offset 0x38 (Matches Reloc: caller)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Address of caller
-      0xDC, 0x01, 0x1A, 0xF8, 0xDE, 0x94, 0x94, 0x0A, # TypeID of caller
+      ## --- Entry 4: caller (caller) ---
+      ## Offset 0x36
+      0x00, ## Format Version
+      0x07, ## Flags (HasDirectCallees | IsIndirectTarget | ...)
+      ## Offset 0x38 (Matches Reloc: caller)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Address of caller
+      0xDC, 0x01, 0x1A, 0xF8, 0xDE, 0x94, 0x94, 0x0A, ## TypeID of caller
 
-      # Direct Callees List
-      0x03, # NumDirectCallees (3)
-      # Offset 0x49 (Matches Reloc: foo)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 1: foo
-      # Offset 0x51 (Matches Reloc: bar)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 2: bar
-      # Offset 0x59 (Matches Reloc: baz)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # Callee 3: baz
+      ## Direct Callees List
+      0x03, ## NumDirectCallees (3)
+      ## Offset 0x49 (Matches Reloc: foo)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Callee 1: foo
+      ## Offset 0x51 (Matches Reloc: bar)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Callee 2: bar
+      ## Offset 0x59 (Matches Reloc: baz)
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Callee 3: baz
 
-      # Indirect Callees List
-      0x02, # NumIndirectTargetTypeIDs (2)
-      0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, # Indirect TypeID 1 (matches foo/bar)
-      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30  # Indirect TypeID 2 (matches baz)
+      ## Indirect Callees List
+      0x02, ## NumIndirectTargetTypeIDs (2)
+      0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, ## Indirect TypeID 1 (matches foo/bar)
+      0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30  ## Indirect TypeID 2 (matches baz)
     ]
   - Name:   .rela.llvm.callgraph
     Type:   SHT_RELA
@@ -498,18 +498,18 @@ Sections:
     Flags:  [ SHF_LINK_ORDER ]
     Link:   .text
     ContentArray: [
-      # --- foo+1 (Thumb address) ---
-      0x00, # Version
-      0x00, # Flags
-      0x01, 0x00, 0x00, 0x00, # FunctionEntryPC: 0x1 (relative to foo)
-      0xF0, 0xDE, 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12 # FunctionTypeID: 0x123456789ABCDEF0
+      ## --- foo+1 (Thumb address) ---
+      0x00, ## Version
+      0x00, ## Flags
+      0x01, 0x00, 0x00, 0x00, ## FunctionEntryPC: 0x1 (relative to foo)
+      0xF0, 0xDE, 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12 ## FunctionTypeID: 0x123456789ABCDEF0
     ]
   - Name:   .rela.llvm.callgraph
     Type:   SHT_RELA
     Flags:  [ SHF_INFO_LINK ]
     Info:   .llvm.callgraph
     Relocations:
-      - Offset:  0x2 # Offset to FunctionEntryPC
+      - Offset:  0x2 ## Offset to FunctionEntryPC
         Symbol:  foo
         Type:    R_ARM_ABS32
 Symbols:

>From 720978d12a1800006709f4f6cc5f3734d9d76a36 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Jan 2026 00:50:10 +0000
Subject: [PATCH 07/22] Fix verbose inline comments.

---
 .../ELF/call-graph-info-warn-malformed.test   | 30 +++++++++----------
 .../llvm-readobj/ELF/call-graph-info.test     |  8 ++---
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index 3847ba7a1af49..00c687d202a13 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -39,7 +39,7 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- Entry 1: foo (foo) ---
+      ## --- foo ---
       0x01, ## Format Version - only supported value is 0x00
     ]
 Symbols:
@@ -67,7 +67,7 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- Entry 1: foo (foo) ---
+      ## --- foo ---
       0x00, ## Format Version
       ##<Missing flags
     ]
@@ -96,7 +96,7 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- Entry 1: foo (foo) ---
+      ## --- foo ---
       0x00, ## Format Version
       0x08, ## Flags - only valid values are 0x00 to 0x07
     ]
@@ -125,7 +125,7 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- Entry 1: foo (foo) ---
+      ## --- foo ---
       0x00, ## Format Version
       0x00, ## Flags
       ##<Missing function entry PC
@@ -155,7 +155,7 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- Entry 1: foo (foo) ---
+      ## --- foo ---
       0x00, ## Format Version
       0x00, ## Flags
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
@@ -186,7 +186,7 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- Entry 1: foo (foo) ---
+      ## --- foo ---
       0x00, ## Format Version
       0x02, ## Flags (HasDirectCallees)
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
@@ -218,7 +218,7 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- Entry 1: foo (foo) ---
+      ## --- foo ---
       0x00, ## Format Version
       0x02, ## Flags (HasDirectCallees)
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
@@ -251,7 +251,7 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- Entry 1: foo (foo) ---
+      ## --- foo ---
       0x00, ## Format Version
       0x04, ## Flags (HasIndirectCallees)
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
@@ -283,7 +283,7 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- Entry 1: foo (foo) ---
+      ## --- foo ---
       0x00, ## Format Version
       0x04, ## Flags (HasIndirectCallees)
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
@@ -318,7 +318,7 @@ FileHeader:
 Sections:
   - Name: .text
     Type: SHT_PROGBITS
-    Size: 12 # or whatever size is needed for all the data
+    Size: 12 ## or whatever size is needed for all the data
   - Name: .llvm.callgraph
     Type: SHT_LLVM_CALL_GRAPH
     ContentArray: [
@@ -341,24 +341,24 @@ Sections:
       ]
   - Type:   SHT_RELA
     Relocations:
-      # 1. Pointer to foo() definition
+      ## 1. Pointer to foo() definition
       - Offset: 0x2
         Symbol: foo
         Type:   R_X86_64_64
 
-      # 2. Pointer to the call site "callq foo" (offset 5 inside foo)
-      #    We relocate against 'foo' and add 5 to get the address of the instruction.
+      ## 2. Pointer to the call site "callq foo" (offset 5 inside foo)
+      ##    We relocate against 'foo' and add 5 to get the address of the instruction.
       - Offset: 0x13
         Symbol: foo
         Type:   R_X86_64_64
         Addend: 5
 
-      # 3. Pointer to bar() definition
+      ## 3. Pointer to bar() definition
       - Offset: 0x1D
         Symbol: bar
         Type:   R_X86_64_64
 
-      # 4. Pointer to baz() definition
+      ## 4. Pointer to baz() definition
       - Offset: 0x38
         Symbol: baz
         Type:   R_X86_64_64
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
index 91e85c0ca4c42..d879c8d834186 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
@@ -368,7 +368,7 @@ Sections:
     Flags:  [ SHF_LINK_ORDER ]
     Link:   .text
     ContentArray: [
-      ## --- Entry 1: foo (foo) ---
+      ## --- foo ---
       ## Offset 0x0
       0x00, ## Format Version
       0x01, ## Flags
@@ -376,7 +376,7 @@ Sections:
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Address of foo
       0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, ## TypeID of foo
 
-      ## --- Entry 2: bar (bar) ---
+      ## --- bar ---
       ## Offset 0x12
       0x00, ## Format Version
       0x01, ## Flags
@@ -384,7 +384,7 @@ Sections:
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Address of bar
       0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, ## TypeID of bar
 
-      ## --- Entry 3: baz (baz) ---
+      ## --- baz ---
       ## Offset 0x24
       0x00, ## Format Version
       0x01, ## Flags
@@ -392,7 +392,7 @@ Sections:
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Address of baz
       0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30, ## TypeID of baz
 
-      ## --- Entry 4: caller (caller) ---
+      ## --- caller ---
       ## Offset 0x36
       0x00, ## Format Version
       0x07, ## Flags (HasDirectCallees | IsIndirectTarget | ...)

>From 7cfadcff2834f84504503a261dd979f0ac1a7944 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Jan 2026 00:53:14 +0000
Subject: [PATCH 08/22] Remove YAML Size: fields.

---
 .../llvm-readobj/ELF/call-graph-info-warn-malformed.test   | 7 -------
 llvm/test/tools/llvm-readobj/ELF/call-graph-info.test      | 3 ---
 2 files changed, 10 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index 00c687d202a13..a26cb924e30b7 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -35,7 +35,6 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-    Size:  5
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
@@ -63,7 +62,6 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-    Size:  5
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
@@ -92,7 +90,6 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-    Size:  5
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
@@ -121,7 +118,6 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-    Size:  5
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
@@ -151,7 +147,6 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-    Size:  5
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
@@ -279,7 +274,6 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-    Size:  5
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
@@ -318,7 +312,6 @@ FileHeader:
 Sections:
   - Name: .text
     Type: SHT_PROGBITS
-    Size: 12 ## or whatever size is needed for all the data
   - Name: .llvm.callgraph
     Type: SHT_LLVM_CALL_GRAPH
     ContentArray: [
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
index d879c8d834186..d2ff0b33043bf 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
@@ -165,7 +165,6 @@ Sections:
   - Name:   .text
     Type:   SHT_PROGBITS
     Flags:  [ SHF_ALLOC, SHF_EXECINSTR ]
-    Size:   0x2000
   - Name:   .llvm.callgraph
     Type:   SHT_LLVM_CALL_GRAPH
     Flags:  [ SHF_LINK_ORDER ]
@@ -362,7 +361,6 @@ FileHeader:
 Sections:
   - Name:   .text
     Type:   SHT_PROGBITS
-    Size:   0x84
   - Name:   .llvm.callgraph
     Type:   SHT_LLVM_CALL_GRAPH
     Flags:  [ SHF_LINK_ORDER ]
@@ -492,7 +490,6 @@ FileHeader:
 Sections:
   - Name:   .text
     Type:   SHT_PROGBITS
-    Size:   0x100
   - Name:   .llvm.callgraph
     Type:   SHT_LLVM_CALL_GRAPH
     Flags:  [ SHF_LINK_ORDER ]

>From f6b9fee99f1611dad8b209a5738e964ab69f410e Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Jan 2026 01:01:11 +0000
Subject: [PATCH 09/22] Remove unnecessary symbols section

---
 .../tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index a26cb924e30b7..846a485f07006 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -38,11 +38,8 @@ Sections:
   - Name:  .llvm.callgraph
     Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- foo ---
       0x01, ## Format Version - only supported value is 0x00
     ]
-Symbols:
-  - Name:  foo
 ...
 
 ## Check missing flags.

>From ab5c6469a05388e62be75114c082ffdac0dccd9e Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Jan 2026 01:09:29 +0000
Subject: [PATCH 10/22] Remove callgraph section name in YAML for non rela
 tests.

---
 .../ELF/call-graph-info-warn-malformed.test   | 66 +++++--------------
 .../llvm-readobj/ELF/call-graph-info.test     |  3 +-
 2 files changed, 16 insertions(+), 53 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index 846a485f07006..9a7455abbbf91 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -35,8 +35,7 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-  - Name:  .llvm.callgraph
-    Type:  SHT_LLVM_CALL_GRAPH
+  - Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
       0x01, ## Format Version - only supported value is 0x00
     ]
@@ -59,15 +58,11 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-  - Name:  .llvm.callgraph
-    Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [
-      ## --- foo ---
+  - Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [      
       0x00, ## Format Version
       ##<Missing flags
     ]
-Symbols:
-  - Name:  foo
 ...
 
 ## Check Flags.
@@ -87,15 +82,11 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-  - Name:  .llvm.callgraph
-    Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [
-      ## --- foo ---
+  - Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [      
       0x00, ## Format Version
       0x08, ## Flags - only valid values are 0x00 to 0x07
     ]
-Symbols:
-  - Name:  foo
 ...
 
 ## Check missing function entry PC.
@@ -115,16 +106,12 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-  - Name:  .llvm.callgraph
-    Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [
-      ## --- foo ---
+  - Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [      
       0x00, ## Format Version
       0x00, ## Flags
       ##<Missing function entry PC
     ]
-Symbols:
-  - Name:  foo
 ...
 
 ## Check missing function Type ID.
@@ -144,17 +131,13 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-  - Name:  .llvm.callgraph
-    Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [
-      ## --- foo ---
+  - Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [      
       0x00, ## Format Version
       0x00, ## Flags
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
       ##<Missing Type ID
     ]
-Symbols:
-  - Name:  foo
 ...
 
 ## Check missing number of direct callees.
@@ -174,19 +157,14 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-    Size:  5
-  - Name:  .llvm.callgraph
-    Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [
-      ## --- foo ---
+  - Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [      
       0x00, ## Format Version
       0x02, ## Flags (HasDirectCallees)
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## TypeID unknown
       ##<Missing NumDirectCallees (ULEB128)
     ]
-Symbols:
-  - Name:  foo
 ...
 
 ## Check missing direct callee.
@@ -206,11 +184,8 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-    Size:  5
-  - Name:  .llvm.callgraph
-    Type:  SHT_LLVM_CALL_GRAPH
+  - Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- foo ---
       0x00, ## Format Version
       0x02, ## Flags (HasDirectCallees)
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
@@ -218,8 +193,6 @@ Sections:
       0x01, ## NumDirectCallees
       ##<Missing direct callee address
     ]
-Symbols:
-  - Name:  foo
 ...
 
 ## Check missing number of indirect target type IDs.
@@ -239,19 +212,14 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-    Size:  5
-  - Name:  .llvm.callgraph
-    Type:  SHT_LLVM_CALL_GRAPH
+  - Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [
-      ## --- foo ---
       0x00, ## Format Version
       0x04, ## Flags (HasIndirectCallees)
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## TypeID unknown
       ##<Missing NumIndirectTargetTypeIDs (ULEB128)
     ]
-Symbols:
-  - Name:  foo
 ...
 
 ## Check missing indirect target type ID.
@@ -271,10 +239,8 @@ FileHeader:
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
-  - Name:  .llvm.callgraph
-    Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [
-      ## --- foo ---
+  - Type:  SHT_LLVM_CALL_GRAPH
+    ContentArray: [      
       0x00, ## Format Version
       0x04, ## Flags (HasIndirectCallees)
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
@@ -282,8 +248,6 @@ Sections:
       0x01, ## NumIndirectTargetTypeIDs (1)
       ##<Missing indirect call entries here.
     ]
-Symbols:
-  - Name:  foo
 ...
 
 ## Check missing relocation information.
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
index d2ff0b33043bf..9ea583092ed0c 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
@@ -165,8 +165,7 @@ Sections:
   - Name:   .text
     Type:   SHT_PROGBITS
     Flags:  [ SHF_ALLOC, SHF_EXECINSTR ]
-  - Name:   .llvm.callgraph
-    Type:   SHT_LLVM_CALL_GRAPH
+  - Type:   SHT_LLVM_CALL_GRAPH
     Flags:  [ SHF_LINK_ORDER ]
     Link:   .text
     ContentArray: [

>From d8348d6546f4a804192fd58c4cddf8b17445d452 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Jan 2026 01:17:58 +0000
Subject: [PATCH 11/22] Unexpected to unsupported. More pruning of YAML.

---
 .../llvm-readobj/ELF/call-graph-info-warn-malformed.test  | 5 ++---
 llvm/test/tools/llvm-readobj/ELF/call-graph-info.test     | 8 ++------
 llvm/tools/llvm-readobj/ELFDumper.cpp                     | 2 +-
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index 9a7455abbbf91..5629f065dc52a 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -72,7 +72,7 @@ Sections:
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t4 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t4 --check-prefix=WARN-FLAG
 
-# WARN-FLAG: warning: '[[FILE]]': unexpected Flags value [8]
+# WARN-FLAG: warning: '[[FILE]]': unsupported Flags value [8]
 
 --- !ELF
 FileHeader:
@@ -273,8 +273,7 @@ FileHeader:
 Sections:
   - Name: .text
     Type: SHT_PROGBITS
-  - Name: .llvm.callgraph
-    Type: SHT_LLVM_CALL_GRAPH
+  - Type: SHT_LLVM_CALL_GRAPH
     ContentArray: [
         '0', ## Format version number
         '3', ## Flag IsIndirectTarget true, HasDirectCallees true
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
index 9ea583092ed0c..16307b0fac3a4 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
@@ -411,9 +411,7 @@ Sections:
       0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, ## Indirect TypeID 1 (matches foo/bar)
       0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30  ## Indirect TypeID 2 (matches baz)
     ]
-  - Name:   .rela.llvm.callgraph
-    Type:   SHT_RELA
-    Flags:  [ SHF_INFO_LINK ]
+  - Type:   SHT_RELA
     Info:   .llvm.callgraph
     Relocations:
       - Offset:  0x2
@@ -500,9 +498,7 @@ Sections:
       0x01, 0x00, 0x00, 0x00, ## FunctionEntryPC: 0x1 (relative to foo)
       0xF0, 0xDE, 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12 ## FunctionTypeID: 0x123456789ABCDEF0
     ]
-  - Name:   .rela.llvm.callgraph
-    Type:   SHT_RELA
-    Flags:  [ SHF_INFO_LINK ]
+  - Type:   SHT_RELA
     Info:   .llvm.callgraph
     Relocations:
       - Offset:  0x2 ## Offset to FunctionEntryPC
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 894d67ef9e4ee..836f36f197e9b 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5394,7 +5394,7 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
                                             callgraph::HasIndirectCallees;
     constexpr uint8_t ValidMask = static_cast<uint8_t>(ValidFlags);
     if ((FlagsVal & ~ValidMask) != 0) {
-      reportWarning(createError("unexpected Flags value [" +
+      reportWarning(createError("unsupported Flags value [" +
                                 std::to_string(FlagsVal) + "] "),
                     FileName);
       return false;

>From cf1a94b6528ff788e6deacf5a28d99815df3b818 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Jan 2026 03:22:40 +0000
Subject: [PATCH 12/22] Improve message format. Add test cases.

---
 .../ELF/call-graph-info-warn-malformed.test   | 186 +++++++-----------
 llvm/tools/llvm-readobj/ELFDumper.cpp         |  41 ++--
 2 files changed, 82 insertions(+), 145 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index 5629f065dc52a..163a3070674fe 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -19,7 +19,7 @@ FileHeader:
 ...
 
 ## Check format version number.
-# RUN: yaml2obj --docnum=2 %s -o %t2
+# RUN: yaml2obj --docnum=2 -DCONTENT=0x01 %s -o %t2
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t2 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t2 --check-prefix=WARN-FMT-VERSION
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t2 2>&1 | \
@@ -27,46 +27,17 @@ FileHeader:
 
 # WARN-FMT-VERSION: warning: '[[FILE]]': unknown format version value [1] in SHT_LLVM_CALL_GRAPH type section
 
---- !ELF
-FileHeader:
-  Class:    ELFCLASS64
-  Data:     ELFDATA2LSB
-  Type:     ET_DYN
-Sections:
-  - Name:  .text
-    Type:  SHT_PROGBITS
-  - Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [
-      0x01, ## Format Version - only supported value is 0x00
-    ]
-...
-
 ## Check missing flags.
-# RUN: yaml2obj --docnum=3 %s -o %t3
+# RUN: yaml2obj --docnum=2 -DCONTENT=0x00 %s -o %t3
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t3 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t3 --check-prefix=WARN-MISSING-FLAG
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t3 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t3 --check-prefix=WARN-MISSING-FLAG
 
-# WARN-MISSING-FLAG: warning: '[[FILE]]': failed while reading call graph info's Flags unexpected end of data at offset 0x1 while reading [0x1, 0x2)
-
---- !ELF
-FileHeader:
-  Class:    ELFCLASS64
-  Data:     ELFDATA2LSB
-  Type:     ET_DYN
-Sections:
-  - Name:  .text
-    Type:  SHT_PROGBITS
-  - Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [      
-      0x00, ## Format Version
-      ##<Missing flags
-    ]
-...
+# WARN-MISSING-FLAG: warning: '[[FILE]]': failed while reading call graph info's Flags: unexpected end of data at offset 0x1 while reading [0x1, 0x2)
 
-## Check Flags.
-# RUN: yaml2obj --docnum=4 %s -o %t4
+## Check Flags. Only valid Flag values are 0x00 to 0x07.
+# RUN: yaml2obj --docnum=2 -DCONTENT=0x00,0x08 %s -o %t4
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t4 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t4 --check-prefix=WARN-FLAG
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t4 2>&1 | \
@@ -83,20 +54,28 @@ Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
   - Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [      
-      0x00, ## Format Version
-      0x08, ## Flags - only valid values are 0x00 to 0x07
+    ContentArray: [
+      [[CONTENT]],
     ]
 ...
 
 ## Check missing function entry PC.
-# RUN: yaml2obj --docnum=5 %s -o %t5
+# RUN: yaml2obj --docnum=3 -DFUNCPC= %s -o %t5
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t5 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t5 --check-prefix=WARN-MISSING-PC
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t5 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t5 --check-prefix=WARN-MISSING-PC
 
-# WARN-MISSING-PC: warning: '[[FILE]]': failed while reading call graph info function entry PC unexpected end of data at offset 0x2 while reading [0x2, 0xa)
+# WARN-MISSING-PC: warning: '[[FILE]]': failed while reading call graph info function entry PC: unexpected end of data at offset 0x2 while reading [0x2, 0xa)
+
+## Check incomplete function entry PC.
+# RUN: yaml2obj --docnum=3 -DFUNCPC=0x00,0x00,0x00,0x00,0x00,0x00,0x00 %s -o %t6
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t6 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN-INCOMPLETE-PC
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t6 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN-INCOMPLETE-PC
+
+# WARN-INCOMPLETE-PC: warning: '[[FILE]]': failed while reading call graph info function entry PC: unexpected end of data at offset 0x9 while reading [0x2, 0xa)
 
 --- !ELF
 FileHeader:
@@ -110,18 +89,27 @@ Sections:
     ContentArray: [      
       0x00, ## Format Version
       0x00, ## Flags
-      ##<Missing function entry PC
+      [[FUNCPC]],      
     ]
 ...
 
 ## Check missing function Type ID.
-# RUN: yaml2obj --docnum=6 %s -o %t6
+# RUN: yaml2obj --docnum=4 -DTYPEID= %s -o %t6
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t6 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN-MISSING-TYPEID
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t6 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN-MISSING-TYPEID
 
-# WARN-MISSING-TYPEID: warning: '[[FILE]]': failed while reading function type ID unexpected end of data at offset 0xa while reading [0xa, 0x12)
+# WARN-MISSING-TYPEID: warning: '[[FILE]]': failed while reading function type ID: unexpected end of data at offset 0xa while reading [0xa, 0x12)
+
+## Check for incomplete function Type ID.
+# RUN: yaml2obj --docnum=4 -DTYPEID=0x00,0x00 %s -o %t6
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t6 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN-INCOMPLETE-TYPEID
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t6 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN-INCOMPLETE-TYPEID
+
+# WARN-INCOMPLETE-TYPEID: warning: '[[FILE]]': failed while reading function type ID: unexpected end of data at offset 0xc while reading [0xa, 0x12)
 
 --- !ELF
 FileHeader:
@@ -135,130 +123,92 @@ Sections:
     ContentArray: [      
       0x00, ## Format Version
       0x00, ## Flags
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
-      ##<Missing Type ID
+      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ## Function entry address
+      [[TYPEID]],      
     ]
 ...
 
 ## Check missing number of direct callees.
-# RUN: yaml2obj --docnum=7 %s -o %t7
+# RUN: yaml2obj --docnum=5 -DFLAGS=0x02 -DNUMCALLEES= %s -o %t7
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t7 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN-MISSING-DIRECT
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t7 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN-MISSING-DIRECT
 
-# WARN-MISSING-DIRECT: warning: '[[FILE]]': failed while reading number of direct callees unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
-
---- !ELF
-FileHeader:
-  Class:    ELFCLASS64
-  Data:     ELFDATA2LSB
-  Type:     ET_DYN
-Sections:
-  - Name:  .text
-    Type:  SHT_PROGBITS
-  - Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [      
-      0x00, ## Format Version
-      0x02, ## Flags (HasDirectCallees)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## TypeID unknown
-      ##<Missing NumDirectCallees (ULEB128)
-    ]
-...
+# WARN-MISSING-DIRECT: warning: '[[FILE]]': failed while reading number of direct callees: unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
 
 ## Check missing direct callee.
-# RUN: yaml2obj --docnum=8 %s -o %t8
+# RUN: yaml2obj --docnum=5 -DFLAGS=0x02 -DNUMCALLEES=0x01 %s -o %t8
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t8 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN-MISSING-CALLEE
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t8 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN-MISSING-CALLEE
 
-# WARN-MISSING-CALLEE: warning: '[[FILE]]': failed while reading direct callee unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
+# WARN-MISSING-CALLEE: warning: '[[FILE]]': failed while reading direct callee: unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
 
---- !ELF
-FileHeader:
-  Class:    ELFCLASS64
-  Data:     ELFDATA2LSB
-  Type:     ET_DYN
-Sections:
-  - Name:  .text
-    Type:  SHT_PROGBITS
-  - Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [
-      0x00, ## Format Version
-      0x02, ## Flags (HasDirectCallees)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## TypeID unknown
-      0x01, ## NumDirectCallees
-      ##<Missing direct callee address
-    ]
-...
+## Check incomplete direct callee.
+# RUN: yaml2obj --docnum=5 -DFLAGS=0x02 -DNUMCALLEES=0x01,0x00,0x00 %s -o %t8
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t8 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN-INCOMPLETE-CALLEE
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t8 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN-INCOMPLETE-CALLEE
 
-## Check missing number of indirect target type IDs.
-# RUN: yaml2obj --docnum=9 %s -o %t9
-# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t9 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t9 --check-prefix=WARN-MISSING-NUM-INDIRECT
-# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t9 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t9 --check-prefix=WARN-MISSING-NUM-INDIRECT
+# WARN-INCOMPLETE-CALLEE: warning: '[[FILE]]': failed while reading direct callee: unexpected end of data at offset 0x15 while reading [0x13, 0x1b)
 
-# WARN-MISSING-NUM-INDIRECT: warning: '[[FILE]]': failed while reading number of indirect target type IDs unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
+## Check missing number of indirect callees.
+# RUN: yaml2obj --docnum=5 -DFLAGS=0x04 -DNUMCALLEES= %s -o %t7
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t7 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN-MISSING-INDIRECT
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t7 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN-MISSING-INDIRECT
 
---- !ELF
-FileHeader:
-  Class:    ELFCLASS64
-  Data:     ELFDATA2LSB
-  Type:     ET_DYN
-Sections:
-  - Name:  .text
-    Type:  SHT_PROGBITS
-  - Type:  SHT_LLVM_CALL_GRAPH
-    ContentArray: [
-      0x00, ## Format Version
-      0x04, ## Flags (HasIndirectCallees)
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
-      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## TypeID unknown
-      ##<Missing NumIndirectTargetTypeIDs (ULEB128)
-    ]
-...
+# WARN-MISSING-INDIRECT: warning: '[[FILE]]': failed while reading number of indirect target type IDs: unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
 
 ## Check missing indirect target type ID.
-# RUN: yaml2obj --docnum=10 %s -o %t10
+# RUN: yaml2obj --docnum=5 -DFLAGS=0x04 -DNUMCALLEES=0x01 %s -o %t10
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t10 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t10 --check-prefix=WARN-MISSING-INDIRECT-TARGET-TYPE-ID
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t10 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t10 --check-prefix=WARN-MISSING-INDIRECT-TARGET-TYPE-ID
 
-# WARN-MISSING-INDIRECT-TARGET-TYPE-ID: warning: '[[FILE]]': failed while reading indirect target type ID unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
+# WARN-MISSING-INDIRECT-TARGET-TYPE-ID: warning: '[[FILE]]': failed while reading indirect target type ID: unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
+
+## Check incomplete indirect target type ID.
+# RUN: yaml2obj --docnum=5 -DFLAGS=0x04 -DNUMCALLEES=0x01,0x00,0x00 %s -o %t8
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t8 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN-INCOMPLETE-TARGET-TYPE-ID
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t8 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN-INCOMPLETE-TARGET-TYPE-ID
+
+# WARN-INCOMPLETE-TARGET-TYPE-ID: warning: '[[FILE]]': failed while reading indirect target type ID: unexpected end of data at offset 0x15 while reading [0x13, 0x1b)
 
 --- !ELF
 FileHeader:
   Class:    ELFCLASS64
   Data:     ELFDATA2LSB
-  Type:     ET_REL
+  Type:     ET_DYN
 Sections:
   - Name:  .text
     Type:  SHT_PROGBITS
   - Type:  SHT_LLVM_CALL_GRAPH
     ContentArray: [      
       0x00, ## Format Version
-      0x04, ## Flags (HasIndirectCallees)
+      [[FLAGS]],
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Function entry address
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## TypeID unknown
-      0x01, ## NumIndirectTargetTypeIDs (1)
-      ##<Missing indirect call entries here.
+      [[NUMCALLEES]],
     ]
 ...
 
 ## Check missing relocation information.
-# RUN: yaml2obj --docnum=11 %s -o %t11
+# RUN: yaml2obj --docnum=6 %s -o %t11
 # RUN: llvm-readobj --elf-output-style=GNU --call-graph-info %t11 2>&1 | count 0
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t11 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t11 --check-prefix=WARN-NO-RELOC
+# RUN:   FileCheck %s -DFILE=%t11 --check-prefixes=WARN-NO-RELOC,WARN-MISSING-TYPE-ID
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t11 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t11 --check-prefix=WARN-NO-RELOC
+# RUN:   FileCheck %s -DFILE=%t11 --check-prefixes=WARN-NO-RELOC,WARN-MISSING-TYPE-ID
 
-# WARN-NO-RELOC: warning: '[[FILE]]': SHT_LLVM_CALL_GRAPH type section has unknown type id for 2 indirect targets
+# WARN-MISSING-TYPE-ID: warning: '[[FILE]]': SHT_LLVM_CALL_GRAPH type section has unknown type id for 2 indirect targets
 # WARN-NO-RELOC: warning: '[[FILE]]': unknown relocation at offset 2
 # WARN-NO-RELOC: warning: '[[FILE]]': unknown relocation at offset 19
 # WARN-NO-RELOC: warning: '[[FILE]]': unknown relocation at offset 29
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 836f36f197e9b..395bf761910fa 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5349,29 +5349,16 @@ enum Flags : uint8_t {
 } // namespace callgraph
 
 template <class ELFT>
-bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
-  Expected<ArrayRef<uint8_t>> SectionBytesOrErr =
-      Obj.getSectionContents(*CGSection);
-  if (!SectionBytesOrErr) {
-    reportWarning(
-        createError("unable to read the SHT_LLVM_CALL_GRAPH type section " +
-                    toString(SectionBytesOrErr.takeError())),
-        FileName);
-    return false;
-  }
-
-  DataExtractor Data(SectionBytesOrErr.get(), Obj.isLE(),
-                     ObjF.getBytesInAddress());
+bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {  
+  ArrayRef<uint8_t> Contents =
+        unwrapOrError(FileName, Obj.getSectionContents(*CGSection));  
+  DataExtractor Data(Contents, Obj.isLE(), ObjF.getBytesInAddress());
   DataExtractor::Cursor C(0);
   uint64_t UnknownCount = 0;
   while (C && C.tell() < CGSection->sh_size) {
     uint8_t FormatVersionNumber = Data.getU8(C);
-    if (!C) {
-      reportWarning(createError("failed while reading FormatVersionNumber " +
-                                toString(C.takeError())),
-                    FileName);
-      return false;
-    }
+    assert(C && "always expect the one byte read to succeed when C.tell() < CGSection->sh_size is true.");
+    if(!C) consumeError(C.takeError()); // To satisfy builds with assertion disabled mode
     if (FormatVersionNumber != 0) {
       reportWarning(createError("unknown format version value [" +
                                 std::to_string(FormatVersionNumber) +
@@ -5383,7 +5370,7 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
     uint8_t FlagsVal = Data.getU8(C);
     if (!C) {
       reportWarning(
-          createError("failed while reading call graph info's Flags " +
+          createError("failed while reading call graph info's Flags: " +
                       toString(C.takeError())),
           FileName);
       return false;
@@ -5406,7 +5393,7 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
     if (!C) {
       reportWarning(
           createError(
-              "failed while reading call graph info function entry PC " +
+              "failed while reading call graph info function entry PC: " +
               toString(C.takeError())),
           FileName);
       return false;
@@ -5422,7 +5409,7 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
     CGInfo.IsIndirectTarget = IsIndirectTarget;
     uint64_t TypeId = Data.getU64(C);
     if (!C) {
-      reportWarning(createError("failed while reading function type ID " +
+      reportWarning(createError("failed while reading function type ID: " +
                                 toString(C.takeError())),
                     FileName);
       return false;
@@ -5436,7 +5423,7 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
       uint64_t NumDirectCallees = Data.getULEB128(C);
       if (!C) {
         reportWarning(
-            createError("failed while reading number of direct callees " +
+            createError("failed while reading number of direct callees: " +
                         toString(C.takeError())),
             FileName);
         return false;
@@ -5447,7 +5434,7 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
         uint64_t Callee = static_cast<uint64_t>(
             Data.getUnsigned(C, sizeof(typename ELFT::uint)));
         if (!C) {
-          reportWarning(createError("failed while reading direct callee " +
+          reportWarning(createError("failed while reading direct callee: " +
                                     toString(C.takeError())),
                         FileName);
           return false;
@@ -5461,7 +5448,7 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
       if (!C) {
         reportWarning(
             createError(
-                "failed while reading number of indirect target type IDs " +
+                "failed while reading number of indirect target type IDs: " +
                 toString(C.takeError())),
             FileName);
         return false;
@@ -5471,7 +5458,7 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
         uint64_t TargetType = Data.getU64(C);
         if (!C) {
           reportWarning(
-              createError("failed while reading indirect target type ID " +
+              createError("failed while reading indirect target type ID: " +
                           toString(C.takeError())),
               FileName);
           return false;
@@ -8329,7 +8316,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
         return Sec.sh_type == ELF::SHT_LLVM_CALL_GRAPH;
       });
   if (!MapOrErr || MapOrErr->empty()) {
-    reportWarning(createError("no SHT_LLVM_CALL_GRAPH section found " +
+    reportWarning(createError("no SHT_LLVM_CALL_GRAPH section found: " +
                               toString(MapOrErr.takeError())),
                   this->FileName);
     return;

>From 53cdea8731bfb2ed8c5d9fa67ac6194b24245b49 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Jan 2026 03:23:08 +0000
Subject: [PATCH 13/22] Fix formatting

---
 llvm/tools/llvm-readobj/ELFDumper.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 395bf761910fa..77cac8372c0ff 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5349,16 +5349,19 @@ enum Flags : uint8_t {
 } // namespace callgraph
 
 template <class ELFT>
-bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {  
+bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
   ArrayRef<uint8_t> Contents =
-        unwrapOrError(FileName, Obj.getSectionContents(*CGSection));  
+      unwrapOrError(FileName, Obj.getSectionContents(*CGSection));
   DataExtractor Data(Contents, Obj.isLE(), ObjF.getBytesInAddress());
   DataExtractor::Cursor C(0);
   uint64_t UnknownCount = 0;
   while (C && C.tell() < CGSection->sh_size) {
     uint8_t FormatVersionNumber = Data.getU8(C);
-    assert(C && "always expect the one byte read to succeed when C.tell() < CGSection->sh_size is true.");
-    if(!C) consumeError(C.takeError()); // To satisfy builds with assertion disabled mode
+    assert(C && "always expect the one byte read to succeed when C.tell() < "
+                "CGSection->sh_size is true.");
+    if (!C)
+      consumeError(
+          C.takeError()); // To satisfy builds with assertion disabled mode
     if (FormatVersionNumber != 0) {
       reportWarning(createError("unknown format version value [" +
                                 std::to_string(FormatVersionNumber) +

>From e4122e21e51564d8c62674cd74aadb82f8d45a7a Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 16 Jan 2026 03:47:57 +0000
Subject: [PATCH 14/22] Evolv ARM thumb clearing comment.

---
 llvm/tools/llvm-readobj/ELFDumper.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 77cac8372c0ff..1cfcd04f8894b 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -8383,7 +8383,9 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
 
   auto PrintFunc = [&](uint64_t FuncPC) {
     uint64_t FuncEntryPC = FuncPC;
-    // Clear Thumb bit if it was set before symbol lookup.
+    // In ARM thumb mode the LSB of the function pointer is set to 1. Since this
+    // detail is unncessary in call graph reconstruction, we are clearing this
+    // bit to facilate tooling.
     if (this->Obj.getHeader().e_machine == ELF::EM_ARM)
       FuncEntryPC = FuncPC & ~1;
     if (this->Obj.getHeader().e_type == ELF::ET_REL)

>From e16a488c52e541cdfbc005a53886bd7edbbfecc4 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Wed, 28 Jan 2026 21:55:12 +0000
Subject: [PATCH 15/22] Address review comments.

---
 llvm/docs/CommandGuide/llvm-readelf.rst       |  2 +-
 llvm/docs/CommandGuide/llvm-readobj.rst       |  2 +-
 .../ELF/call-graph-info-warn-malformed.test   | 22 +++++++++----------
 llvm/tools/llvm-readobj/ELFDumper.cpp         |  7 ++----
 4 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/llvm/docs/CommandGuide/llvm-readelf.rst b/llvm/docs/CommandGuide/llvm-readelf.rst
index ed349d1d15761..35eeb41dff8ed 100644
--- a/llvm/docs/CommandGuide/llvm-readelf.rst
+++ b/llvm/docs/CommandGuide/llvm-readelf.rst
@@ -42,7 +42,7 @@ OPTIONS
 
   Display the call graph section entries i.e. for each function
   its identifying information, each of its direct callees' information
-  and for each indirect callee a 64 bit number representing the callee's
+  and for each indirect callee a 64-bit number representing the callee's
   function signature. This information can be used to reconstruct
   the program call graph.
 
diff --git a/llvm/docs/CommandGuide/llvm-readobj.rst b/llvm/docs/CommandGuide/llvm-readobj.rst
index 5498f9574ad13..4f52cc2f8d998 100644
--- a/llvm/docs/CommandGuide/llvm-readobj.rst
+++ b/llvm/docs/CommandGuide/llvm-readobj.rst
@@ -185,7 +185,7 @@ The following options are implemented only for the ELF file format.
 
   Display the call graph section entries i.e. for each function
   its identifying information, each of its direct callees' information
-  and for each indirect callee a 64 bit number representing the callee's
+  and for each indirect callee a 64-bit number representing the callee's
   function signature. This information can be used to reconstruct
   the program call graph.
 
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index 163a3070674fe..1441de7962ad9 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -1,8 +1,8 @@
-## Tests that --call-graph-info produces useful warnings
-## if SHT_LLVM_CALL_GRAPH type section processing idenitifies
-## malformed content.
+## Tests that --call-graph-info produces useful warnings if SHT_LLVM_CALL_GRAPH
+## type section processing identifies malformed content.
 
-## Tests that --call-graph-info warns if there is no section of type SHT_LLVM_CALL_GRAPH.
+## Tests that --call-graph-info warns if there is no section of type
+## SHT_LLVM_CALL_GRAPH.
 # RUN: yaml2obj --docnum=1 %s -o %t1
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t1 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t1 --check-prefix=WARN-NO-SECTION
@@ -204,15 +204,15 @@ Sections:
 # RUN: yaml2obj --docnum=6 %s -o %t11
 # RUN: llvm-readobj --elf-output-style=GNU --call-graph-info %t11 2>&1 | count 0
 # RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t11 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t11 --check-prefixes=WARN-NO-RELOC,WARN-MISSING-TYPE-ID
+# RUN:   FileCheck %s -DFILE=%t11 --check-prefixes=WARN-MISSING-INFO
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t11 2>&1 | \
-# RUN:   FileCheck %s -DFILE=%t11 --check-prefixes=WARN-NO-RELOC,WARN-MISSING-TYPE-ID
+# RUN:   FileCheck %s -DFILE=%t11 --check-prefixes=WARN-MISSING-INFO
 
-# WARN-MISSING-TYPE-ID: warning: '[[FILE]]': SHT_LLVM_CALL_GRAPH type section has unknown type id for 2 indirect targets
-# WARN-NO-RELOC: warning: '[[FILE]]': unknown relocation at offset 2
-# WARN-NO-RELOC: warning: '[[FILE]]': unknown relocation at offset 19
-# WARN-NO-RELOC: warning: '[[FILE]]': unknown relocation at offset 29
-# WARN-NO-RELOC: warning: '[[FILE]]': unknown relocation at offset 56
+# WARN-MISSING-INFO: warning: '[[FILE]]': SHT_LLVM_CALL_GRAPH type section has unknown type id for 2 indirect targets
+# WARN-MISSING-INFO: warning: '[[FILE]]': unknown relocation at offset 2
+# WARN-MISSING-INFO: warning: '[[FILE]]': unknown relocation at offset 19
+# WARN-MISSING-INFO: warning: '[[FILE]]': unknown relocation at offset 29
+# WARN-MISSING-INFO: warning: '[[FILE]]': unknown relocation at offset 56
 
 --- !ELF
 FileHeader:
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 1cfcd04f8894b..182eb8cae141f 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Object/ELF.h"
 #include "llvm/Object/ELFObjectFile.h"
 #include "llvm/Object/ELFTypes.h"
+#include "llvm/Object/Error.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Object/RelocationResolver.h"
 #include "llvm/Object/SFrameParser.h"
@@ -5350,8 +5351,7 @@ enum Flags : uint8_t {
 
 template <class ELFT>
 bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
-  ArrayRef<uint8_t> Contents =
-      unwrapOrError(FileName, Obj.getSectionContents(*CGSection));
+  ArrayRef<uint8_t> Contents = cantFail(Obj.getSectionContents(*CGSection));
   DataExtractor Data(Contents, Obj.isLE(), ObjF.getBytesInAddress());
   DataExtractor::Cursor C(0);
   uint64_t UnknownCount = 0;
@@ -5359,9 +5359,6 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
     uint8_t FormatVersionNumber = Data.getU8(C);
     assert(C && "always expect the one byte read to succeed when C.tell() < "
                 "CGSection->sh_size is true.");
-    if (!C)
-      consumeError(
-          C.takeError()); // To satisfy builds with assertion disabled mode
     if (FormatVersionNumber != 0) {
       reportWarning(createError("unknown format version value [" +
                                 std::to_string(FormatVersionNumber) +

>From 502218647035cc29063f35902dae8228eb9854a8 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Tue, 3 Feb 2026 23:04:26 +0000
Subject: [PATCH 16/22] Remove duplicate Flags enum definition

---
 llvm/tools/llvm-readobj/ELFDumper.cpp | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 4e14c2e61b76b..e073a6c094bac 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5341,17 +5341,6 @@ template <class ELFT> void GNUELFDumper<ELFT>::printCGProfile() {
   OS << "GNUStyle::printCGProfile not implemented\n";
 }
 
-namespace callgraph {
-LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
-enum Flags : uint8_t {
-  None = 0,
-  IsIndirectTarget = 1u << 0,
-  HasDirectCallees = 1u << 1,
-  HasIndirectCallees = 1u << 2,
-  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue*/ HasIndirectCallees)
-};
-} // namespace callgraph
-
 template <class ELFT>
 bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
   ArrayRef<uint8_t> Contents = cantFail(Obj.getSectionContents(*CGSection));

>From 225af61e2dca58211f8bc6a82ddadf53111964d1 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Tue, 3 Feb 2026 23:07:59 +0000
Subject: [PATCH 17/22] IndirectTypeIDs* to IndirectTypeIds*

---
 .../llvm-readobj/ELF/call-graph-info.test     | 36 +++++++++----------
 llvm/tools/llvm-readobj/ELFDumper.cpp         | 12 +++----
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
index 16307b0fac3a4..b5fe35c1b5006 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
@@ -19,7 +19,7 @@
 # LLVM-NONRELOC-NEXT:       DirectCallees [
 # LLVM-NONRELOC-NEXT:       ]
 # LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
-# LLVM-NONRELOC-NEXT:       IndirectTypeIDs: []
+# LLVM-NONRELOC-NEXT:       IndirectTypeIds: []
 # LLVM-NONRELOC-NEXT:     }
 # LLVM-NONRELOC-NEXT:     Function {
 # LLVM-NONRELOC-NEXT:       Names: [bar]
@@ -31,7 +31,7 @@
 # LLVM-NONRELOC-NEXT:       DirectCallees [
 # LLVM-NONRELOC-NEXT:       ]
 # LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
-# LLVM-NONRELOC-NEXT:       IndirectTypeIDs: []
+# LLVM-NONRELOC-NEXT:       IndirectTypeIds: []
 # LLVM-NONRELOC-NEXT:     }
 # LLVM-NONRELOC-NEXT:     Function {
 # LLVM-NONRELOC-NEXT:       Names: [baz]
@@ -43,7 +43,7 @@
 # LLVM-NONRELOC-NEXT:       DirectCallees [
 # LLVM-NONRELOC-NEXT:       ]
 # LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
-# LLVM-NONRELOC-NEXT:       IndirectTypeIDs: []
+# LLVM-NONRELOC-NEXT:       IndirectTypeIds: []
 # LLVM-NONRELOC-NEXT:     }
 # LLVM-NONRELOC-NEXT:     Function {
 # LLVM-NONRELOC-NEXT:       Names: [main]
@@ -67,7 +67,7 @@
 # LLVM-NONRELOC-NEXT:         }
 # LLVM-NONRELOC-NEXT:       ]
 # LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 2
-# LLVM-NONRELOC-NEXT:       IndirectTypeIDs: [0x3ECBEEF531F74424, 0x308E4B8159BC8654]
+# LLVM-NONRELOC-NEXT:       IndirectTypeIds: [0x3ECBEEF531F74424, 0x308E4B8159BC8654]
 # LLVM-NONRELOC-NEXT:     }
 # LLVM-NONRELOC-NEXT:   ]
 
@@ -84,7 +84,7 @@
 # JSON-NONRELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-NONRELOC-NEXT:          "DirectCallees": [],
 # JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON-NONRELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-NONRELOC-NEXT:          "IndirectTypeIds": []
 # JSON-NONRELOC-NEXT:        }
 # JSON-NONRELOC-NEXT:      },
 # JSON-NONRELOC-NEXT:      {
@@ -99,7 +99,7 @@
 # JSON-NONRELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-NONRELOC-NEXT:          "DirectCallees": [],
 # JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON-NONRELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-NONRELOC-NEXT:          "IndirectTypeIds": []
 # JSON-NONRELOC-NEXT:        }
 # JSON-NONRELOC-NEXT:      },
 # JSON-NONRELOC-NEXT:      {
@@ -114,7 +114,7 @@
 # JSON-NONRELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-NONRELOC-NEXT:          "DirectCallees": [],
 # JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON-NONRELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-NONRELOC-NEXT:          "IndirectTypeIds": []
 # JSON-NONRELOC-NEXT:        }
 # JSON-NONRELOC-NEXT:      },
 # JSON-NONRELOC-NEXT:      {
@@ -148,7 +148,7 @@
 # JSON-NONRELOC-NEXT:            }
 # JSON-NONRELOC-NEXT:          ],
 # JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 2,
-# JSON-NONRELOC-NEXT:          "IndirectTypeIDs": [
+# JSON-NONRELOC-NEXT:          "IndirectTypeIds": [
 # JSON-NONRELOC-NEXT:            4524972987496481828,
 # JSON-NONRELOC-NEXT:            3498816979441845844
 # JSON-NONRELOC-NEXT:          ]
@@ -241,7 +241,7 @@ Symbols:
 # LLVM-RELOC-NEXT:     DirectCallees [
 # LLVM-RELOC-NEXT:     ]
 # LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
-# LLVM-RELOC-NEXT:     IndirectTypeIDs: []
+# LLVM-RELOC-NEXT:     IndirectTypeIds: []
 # LLVM-RELOC-NEXT:   }
 # LLVM-RELOC-NEXT:   Function {
 # LLVM-RELOC-NEXT:     Name: bar
@@ -252,7 +252,7 @@ Symbols:
 # LLVM-RELOC-NEXT:     DirectCallees [
 # LLVM-RELOC-NEXT:     ]
 # LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
-# LLVM-RELOC-NEXT:     IndirectTypeIDs: []
+# LLVM-RELOC-NEXT:     IndirectTypeIds: []
 # LLVM-RELOC-NEXT:   }
 # LLVM-RELOC-NEXT:   Function {
 # LLVM-RELOC-NEXT:     Name: baz
@@ -263,7 +263,7 @@ Symbols:
 # LLVM-RELOC-NEXT:     DirectCallees [
 # LLVM-RELOC-NEXT:     ]
 # LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
-# LLVM-RELOC-NEXT:     IndirectTypeIDs: []
+# LLVM-RELOC-NEXT:     IndirectTypeIds: []
 # LLVM-RELOC-NEXT:   }
 # LLVM-RELOC-NEXT:   Function {
 # LLVM-RELOC-NEXT:     Name: caller
@@ -283,7 +283,7 @@ Symbols:
 # LLVM-RELOC-NEXT:       }
 # LLVM-RELOC-NEXT:     ]
 # LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 2
-# LLVM-RELOC-NEXT:     IndirectTypeIDs: [0xF85C699BB8EF20A2, 0x308E4B8159BC8654]
+# LLVM-RELOC-NEXT:     IndirectTypeIds: [0xF85C699BB8EF20A2, 0x308E4B8159BC8654]
 # LLVM-RELOC-NEXT:   }
 # LLVM-RELOC-NEXT: ]
 
@@ -297,7 +297,7 @@ Symbols:
 # JSON-RELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-RELOC-NEXT:          "DirectCallees": [],
 # JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON-RELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-RELOC-NEXT:          "IndirectTypeIds": []
 # JSON-RELOC-NEXT:        }
 # JSON-RELOC-NEXT:      },
 # JSON-RELOC-NEXT:      {
@@ -309,7 +309,7 @@ Symbols:
 # JSON-RELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-RELOC-NEXT:          "DirectCallees": [],
 # JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON-RELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-RELOC-NEXT:          "IndirectTypeIds": []
 # JSON-RELOC-NEXT:        }
 # JSON-RELOC-NEXT:      },
 # JSON-RELOC-NEXT:      {
@@ -321,7 +321,7 @@ Symbols:
 # JSON-RELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-RELOC-NEXT:          "DirectCallees": [],
 # JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
-# JSON-RELOC-NEXT:          "IndirectTypeIDs": []
+# JSON-RELOC-NEXT:          "IndirectTypeIds": []
 # JSON-RELOC-NEXT:        }
 # JSON-RELOC-NEXT:      },
 # JSON-RELOC-NEXT:      {
@@ -343,7 +343,7 @@ Symbols:
 # JSON-RELOC-NEXT:            }
 # JSON-RELOC-NEXT:          ],
 # JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 2,
-# JSON-RELOC-NEXT:          "IndirectTypeIDs": [
+# JSON-RELOC-NEXT:          "IndirectTypeIds": [
 # JSON-RELOC-NEXT:            17896295136807035042,
 # JSON-RELOC-NEXT:            3498816979441845844
 # JSON-RELOC-NEXT:          ]
@@ -459,7 +459,7 @@ Symbols:
 # LLVM-ARM-THUMB-NEXT:     DirectCallees [
 # LLVM-ARM-THUMB-NEXT:     ]
 # LLVM-ARM-THUMB-NEXT:     NumIndirectTargetTypeIDs: 0
-# LLVM-ARM-THUMB-NEXT:     IndirectTypeIDs: []
+# LLVM-ARM-THUMB-NEXT:     IndirectTypeIds: []
 # LLVM-ARM-THUMB-NEXT:   }
 # LLVM-ARM-THUMB-NEXT: ]
 
@@ -473,7 +473,7 @@ Symbols:
 # JSON-ARM-THUMB-NEXT:        "NumDirectCallees": 0,
 # JSON-ARM-THUMB-NEXT:        "DirectCallees": [],
 # JSON-ARM-THUMB-NEXT:        "NumIndirectTargetTypeIDs": 0,
-# JSON-ARM-THUMB-NEXT:        "IndirectTypeIDs": []
+# JSON-ARM-THUMB-NEXT:        "IndirectTypeIds": []
 # JSON-ARM-THUMB-NEXT:      }
 # JSON-ARM-THUMB-NEXT:    }
 # JSON-ARM-THUMB-NEXT:  ]
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index e073a6c094bac..dfee4d035b3e0 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -190,7 +190,7 @@ struct FunctionCallgraphInfo {
   bool IsIndirectTarget;
   uint64_t FunctionTypeId;
   SmallSet<uint64_t, 4> DirectCallees;
-  SmallSet<uint64_t, 4> IndirectTypeIDs;
+  SmallSet<uint64_t, 4> IndirectTypeIds;
 };
 
 namespace {
@@ -5455,7 +5455,7 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
               FileName);
           return false;
         }
-        CGInfo.IndirectTypeIDs.insert(TargetType);
+        CGInfo.IndirectTypeIds.insert(TargetType);
       }
     }
     FuncCGInfos.push_back(CGInfo);
@@ -8400,10 +8400,10 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
         PrintFunc(CalleePC);
       }
     }
-    W.printNumber("NumIndirectTargetTypeIDs", CGInfo.IndirectTypeIDs.size());
-    SmallVector<uint64_t, 4> IndirectTypeIdsList(CGInfo.IndirectTypeIDs.begin(),
-                                                 CGInfo.IndirectTypeIDs.end());
-    W.printHexList("IndirectTypeIDs", ArrayRef(IndirectTypeIdsList));
+    W.printNumber("NumIndirectTargetTypeIDs", CGInfo.IndirectTypeIds.size());
+    SmallVector<uint64_t, 4> IndirectTypeIdsList(CGInfo.IndirectTypeIds.begin(),
+                                                 CGInfo.IndirectTypeIds.end());
+    W.printHexList("IndirectTypeIds", ArrayRef(IndirectTypeIdsList));
   }
 }
 

>From 9afee7f6b57d222da46800ef64cd5aec7811c9e5 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Tue, 3 Feb 2026 23:12:57 +0000
Subject: [PATCH 18/22] Other ID to Id

---
 .../ELF/call-graph-info-warn-malformed.test   | 12 +++---
 .../llvm-readobj/ELF/call-graph-info.test     | 40 +++++++++----------
 llvm/tools/llvm-readobj/ELFDumper.cpp         | 14 +++----
 3 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index 1441de7962ad9..a5810616dbcde 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -100,7 +100,7 @@ Sections:
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t6 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN-MISSING-TYPEID
 
-# WARN-MISSING-TYPEID: warning: '[[FILE]]': failed while reading function type ID: unexpected end of data at offset 0xa while reading [0xa, 0x12)
+# WARN-MISSING-TYPEID: warning: '[[FILE]]': failed while reading function type Id: unexpected end of data at offset 0xa while reading [0xa, 0x12)
 
 ## Check for incomplete function Type ID.
 # RUN: yaml2obj --docnum=4 -DTYPEID=0x00,0x00 %s -o %t6
@@ -109,7 +109,7 @@ Sections:
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t6 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t6 --check-prefix=WARN-INCOMPLETE-TYPEID
 
-# WARN-INCOMPLETE-TYPEID: warning: '[[FILE]]': failed while reading function type ID: unexpected end of data at offset 0xc while reading [0xa, 0x12)
+# WARN-INCOMPLETE-TYPEID: warning: '[[FILE]]': failed while reading function type Id: unexpected end of data at offset 0xc while reading [0xa, 0x12)
 
 --- !ELF
 FileHeader:
@@ -162,7 +162,7 @@ Sections:
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t7 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t7 --check-prefix=WARN-MISSING-INDIRECT
 
-# WARN-MISSING-INDIRECT: warning: '[[FILE]]': failed while reading number of indirect target type IDs: unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
+# WARN-MISSING-INDIRECT: warning: '[[FILE]]': failed while reading number of indirect target type Ids: unable to decode LEB128 at offset 0x00000012: malformed uleb128, extends past end
 
 ## Check missing indirect target type ID.
 # RUN: yaml2obj --docnum=5 -DFLAGS=0x04 -DNUMCALLEES=0x01 %s -o %t10
@@ -171,7 +171,7 @@ Sections:
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t10 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t10 --check-prefix=WARN-MISSING-INDIRECT-TARGET-TYPE-ID
 
-# WARN-MISSING-INDIRECT-TARGET-TYPE-ID: warning: '[[FILE]]': failed while reading indirect target type ID: unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
+# WARN-MISSING-INDIRECT-TARGET-TYPE-ID: warning: '[[FILE]]': failed while reading indirect target type Id: unexpected end of data at offset 0x13 while reading [0x13, 0x1b)
 
 ## Check incomplete indirect target type ID.
 # RUN: yaml2obj --docnum=5 -DFLAGS=0x04 -DNUMCALLEES=0x01,0x00,0x00 %s -o %t8
@@ -180,7 +180,7 @@ Sections:
 # RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t8 2>&1 | \
 # RUN:   FileCheck %s -DFILE=%t8 --check-prefix=WARN-INCOMPLETE-TARGET-TYPE-ID
 
-# WARN-INCOMPLETE-TARGET-TYPE-ID: warning: '[[FILE]]': failed while reading indirect target type ID: unexpected end of data at offset 0x15 while reading [0x13, 0x1b)
+# WARN-INCOMPLETE-TARGET-TYPE-ID: warning: '[[FILE]]': failed while reading indirect target type Id: unexpected end of data at offset 0x15 while reading [0x13, 0x1b)
 
 --- !ELF
 FileHeader:
@@ -235,7 +235,7 @@ Sections:
         '5', ## Flag IsIndirectTarget true, HasIndirectTargetTypeIDs true
         '6', '0', '0', '0', '0', '0', '0', '0', ## bar()'s address
         '0', '0', '0', '0', '0', '0', '0', '0', ## bar()'s TypeID Unknown
-        '1', ## NumIndirectTargetTypeIDs
+        '1', ## NumIndirectTargetTypeIds
         '16', '0', '0', '0', '0', '0', '0', '0', ## Indirect callee type ID
         '0', ## Format version number
         '1', ## Flag IsIndirectTarget true
diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
index b5fe35c1b5006..259142dcd6415 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info.test
@@ -18,7 +18,7 @@
 # LLVM-NONRELOC-NEXT:       NumDirectCallees: 0
 # LLVM-NONRELOC-NEXT:       DirectCallees [
 # LLVM-NONRELOC-NEXT:       ]
-# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
+# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIds: 0
 # LLVM-NONRELOC-NEXT:       IndirectTypeIds: []
 # LLVM-NONRELOC-NEXT:     }
 # LLVM-NONRELOC-NEXT:     Function {
@@ -30,7 +30,7 @@
 # LLVM-NONRELOC-NEXT:       NumDirectCallees: 0
 # LLVM-NONRELOC-NEXT:       DirectCallees [
 # LLVM-NONRELOC-NEXT:       ]
-# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
+# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIds: 0
 # LLVM-NONRELOC-NEXT:       IndirectTypeIds: []
 # LLVM-NONRELOC-NEXT:     }
 # LLVM-NONRELOC-NEXT:     Function {
@@ -42,7 +42,7 @@
 # LLVM-NONRELOC-NEXT:       NumDirectCallees: 0
 # LLVM-NONRELOC-NEXT:       DirectCallees [
 # LLVM-NONRELOC-NEXT:       ]
-# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 0
+# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIds: 0
 # LLVM-NONRELOC-NEXT:       IndirectTypeIds: []
 # LLVM-NONRELOC-NEXT:     }
 # LLVM-NONRELOC-NEXT:     Function {
@@ -66,7 +66,7 @@
 # LLVM-NONRELOC-NEXT:           Address: 0x17B0
 # LLVM-NONRELOC-NEXT:         }
 # LLVM-NONRELOC-NEXT:       ]
-# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIDs: 2
+# LLVM-NONRELOC-NEXT:       NumIndirectTargetTypeIds: 2
 # LLVM-NONRELOC-NEXT:       IndirectTypeIds: [0x3ECBEEF531F74424, 0x308E4B8159BC8654]
 # LLVM-NONRELOC-NEXT:     }
 # LLVM-NONRELOC-NEXT:   ]
@@ -83,7 +83,7 @@
 # JSON-NONRELOC-NEXT:          "TypeId": 4524972987496481828,
 # JSON-NONRELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-NONRELOC-NEXT:          "DirectCallees": [],
-# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIds": 0,
 # JSON-NONRELOC-NEXT:          "IndirectTypeIds": []
 # JSON-NONRELOC-NEXT:        }
 # JSON-NONRELOC-NEXT:      },
@@ -98,7 +98,7 @@
 # JSON-NONRELOC-NEXT:          "TypeId": 4524972987496481828,
 # JSON-NONRELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-NONRELOC-NEXT:          "DirectCallees": [],
-# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIds": 0,
 # JSON-NONRELOC-NEXT:          "IndirectTypeIds": []
 # JSON-NONRELOC-NEXT:        }
 # JSON-NONRELOC-NEXT:      },
@@ -113,7 +113,7 @@
 # JSON-NONRELOC-NEXT:          "TypeId": 3498816979441845844,
 # JSON-NONRELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-NONRELOC-NEXT:          "DirectCallees": [],
-# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIds": 0,
 # JSON-NONRELOC-NEXT:          "IndirectTypeIds": []
 # JSON-NONRELOC-NEXT:        }
 # JSON-NONRELOC-NEXT:      },
@@ -147,7 +147,7 @@
 # JSON-NONRELOC-NEXT:              "Address": 6064
 # JSON-NONRELOC-NEXT:            }
 # JSON-NONRELOC-NEXT:          ],
-# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIDs": 2,
+# JSON-NONRELOC-NEXT:          "NumIndirectTargetTypeIds": 2,
 # JSON-NONRELOC-NEXT:          "IndirectTypeIds": [
 # JSON-NONRELOC-NEXT:            4524972987496481828,
 # JSON-NONRELOC-NEXT:            3498816979441845844
@@ -200,7 +200,7 @@ Sections:
       0xB0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Callee 3: 0x17B0 (baz)
 
       ## Indirect Callees
-      0x02, ## NumIndirectTargetTypeIDs
+      0x02, ## NumIndirectTargetTypeIds
       0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, ## TypeID 1
       0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30  ## TypeID 2
     ]
@@ -240,7 +240,7 @@ Symbols:
 # LLVM-RELOC-NEXT:     NumDirectCallees: 0
 # LLVM-RELOC-NEXT:     DirectCallees [
 # LLVM-RELOC-NEXT:     ]
-# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIds: 0
 # LLVM-RELOC-NEXT:     IndirectTypeIds: []
 # LLVM-RELOC-NEXT:   }
 # LLVM-RELOC-NEXT:   Function {
@@ -251,7 +251,7 @@ Symbols:
 # LLVM-RELOC-NEXT:     NumDirectCallees: 0
 # LLVM-RELOC-NEXT:     DirectCallees [
 # LLVM-RELOC-NEXT:     ]
-# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIds: 0
 # LLVM-RELOC-NEXT:     IndirectTypeIds: []
 # LLVM-RELOC-NEXT:   }
 # LLVM-RELOC-NEXT:   Function {
@@ -262,7 +262,7 @@ Symbols:
 # LLVM-RELOC-NEXT:     NumDirectCallees: 0
 # LLVM-RELOC-NEXT:     DirectCallees [
 # LLVM-RELOC-NEXT:     ]
-# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIds: 0
 # LLVM-RELOC-NEXT:     IndirectTypeIds: []
 # LLVM-RELOC-NEXT:   }
 # LLVM-RELOC-NEXT:   Function {
@@ -282,7 +282,7 @@ Symbols:
 # LLVM-RELOC-NEXT:         Name: baz
 # LLVM-RELOC-NEXT:       }
 # LLVM-RELOC-NEXT:     ]
-# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIDs: 2
+# LLVM-RELOC-NEXT:     NumIndirectTargetTypeIds: 2
 # LLVM-RELOC-NEXT:     IndirectTypeIds: [0xF85C699BB8EF20A2, 0x308E4B8159BC8654]
 # LLVM-RELOC-NEXT:   }
 # LLVM-RELOC-NEXT: ]
@@ -296,7 +296,7 @@ Symbols:
 # JSON-RELOC-NEXT:          "TypeId": 17896295136807035042,
 # JSON-RELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-RELOC-NEXT:          "DirectCallees": [],
-# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIds": 0,
 # JSON-RELOC-NEXT:          "IndirectTypeIds": []
 # JSON-RELOC-NEXT:        }
 # JSON-RELOC-NEXT:      },
@@ -308,7 +308,7 @@ Symbols:
 # JSON-RELOC-NEXT:          "TypeId": 17896295136807035042,
 # JSON-RELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-RELOC-NEXT:          "DirectCallees": [],
-# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIds": 0,
 # JSON-RELOC-NEXT:          "IndirectTypeIds": []
 # JSON-RELOC-NEXT:        }
 # JSON-RELOC-NEXT:      },
@@ -320,7 +320,7 @@ Symbols:
 # JSON-RELOC-NEXT:          "TypeId": 3498816979441845844,
 # JSON-RELOC-NEXT:          "NumDirectCallees": 0,
 # JSON-RELOC-NEXT:          "DirectCallees": [],
-# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 0,
+# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIds": 0,
 # JSON-RELOC-NEXT:          "IndirectTypeIds": []
 # JSON-RELOC-NEXT:        }
 # JSON-RELOC-NEXT:      },
@@ -342,7 +342,7 @@ Symbols:
 # JSON-RELOC-NEXT:              "Name": "baz"
 # JSON-RELOC-NEXT:            }
 # JSON-RELOC-NEXT:          ],
-# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIDs": 2,
+# JSON-RELOC-NEXT:          "NumIndirectTargetTypeIds": 2,
 # JSON-RELOC-NEXT:          "IndirectTypeIds": [
 # JSON-RELOC-NEXT:            17896295136807035042,
 # JSON-RELOC-NEXT:            3498816979441845844
@@ -407,7 +407,7 @@ Sections:
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## Callee 3: baz
 
       ## Indirect Callees List
-      0x02, ## NumIndirectTargetTypeIDs (2)
+      0x02, ## NumIndirectTargetTypeIds (2)
       0xA2, 0x20, 0xEF, 0xB8, 0x9B, 0x69, 0x5C, 0xF8, ## Indirect TypeID 1 (matches foo/bar)
       0x54, 0x86, 0xBC, 0x59, 0x81, 0x4B, 0x8E, 0x30  ## Indirect TypeID 2 (matches baz)
     ]
@@ -458,7 +458,7 @@ Symbols:
 # LLVM-ARM-THUMB-NEXT:     NumDirectCallees: 0
 # LLVM-ARM-THUMB-NEXT:     DirectCallees [
 # LLVM-ARM-THUMB-NEXT:     ]
-# LLVM-ARM-THUMB-NEXT:     NumIndirectTargetTypeIDs: 0
+# LLVM-ARM-THUMB-NEXT:     NumIndirectTargetTypeIds: 0
 # LLVM-ARM-THUMB-NEXT:     IndirectTypeIds: []
 # LLVM-ARM-THUMB-NEXT:   }
 # LLVM-ARM-THUMB-NEXT: ]
@@ -472,7 +472,7 @@ Symbols:
 # JSON-ARM-THUMB-NEXT:        "TypeId": 1311768467463790320,
 # JSON-ARM-THUMB-NEXT:        "NumDirectCallees": 0,
 # JSON-ARM-THUMB-NEXT:        "DirectCallees": [],
-# JSON-ARM-THUMB-NEXT:        "NumIndirectTargetTypeIDs": 0,
+# JSON-ARM-THUMB-NEXT:        "NumIndirectTargetTypeIds": 0,
 # JSON-ARM-THUMB-NEXT:        "IndirectTypeIds": []
 # JSON-ARM-THUMB-NEXT:      }
 # JSON-ARM-THUMB-NEXT:    }
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index dfee4d035b3e0..49854dafc2fe0 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5401,7 +5401,7 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
     CGInfo.IsIndirectTarget = IsIndirectTarget;
     uint64_t TypeId = Data.getU64(C);
     if (!C) {
-      reportWarning(createError("failed while reading function type ID: " +
+      reportWarning(createError("failed while reading function type Id: " +
                                 toString(C.takeError())),
                     FileName);
       return false;
@@ -5436,21 +5436,21 @@ bool ELFDumper<ELFT>::processCallGraphSection(const Elf_Shdr *CGSection) {
     }
 
     if (CGFlags & callgraph::HasIndirectCallees) {
-      uint64_t NumIndirectTargetTypeIDs = Data.getULEB128(C);
+      uint64_t NumIndirectTargetTypeIds = Data.getULEB128(C);
       if (!C) {
         reportWarning(
             createError(
-                "failed while reading number of indirect target type IDs: " +
+                "failed while reading number of indirect target type Ids: " +
                 toString(C.takeError())),
             FileName);
         return false;
       }
-      // Read unique indirect target type IDs and populate FuncCGInfos.
-      for (uint64_t I = 0; I < NumIndirectTargetTypeIDs; ++I) {
+      // Read unique indirect target type Ids and populate FuncCGInfos.
+      for (uint64_t I = 0; I < NumIndirectTargetTypeIds; ++I) {
         uint64_t TargetType = Data.getU64(C);
         if (!C) {
           reportWarning(
-              createError("failed while reading indirect target type ID: " +
+              createError("failed while reading indirect target type Id: " +
                           toString(C.takeError())),
               FileName);
           return false;
@@ -8400,7 +8400,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
         PrintFunc(CalleePC);
       }
     }
-    W.printNumber("NumIndirectTargetTypeIDs", CGInfo.IndirectTypeIds.size());
+    W.printNumber("NumIndirectTargetTypeIds", CGInfo.IndirectTypeIds.size());
     SmallVector<uint64_t, 4> IndirectTypeIdsList(CGInfo.IndirectTypeIds.begin(),
                                                  CGInfo.IndirectTypeIds.end());
     W.printHexList("IndirectTypeIds", ArrayRef(IndirectTypeIdsList));

>From 771ff075dc21dda623650e8f3e2bb3e252fd3dd4 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Tue, 3 Feb 2026 23:16:09 +0000
Subject: [PATCH 19/22] Remove use of auto where the type is not clear.

---
 llvm/tools/llvm-readobj/ELFDumper.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 49854dafc2fe0..4f63cac349029 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -8386,7 +8386,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
   };
 
   ListScope CGI(W, "CallGraph");
-  for (const auto &CGInfo : this->FuncCGInfos) {
+  for (const FunctionCallgraphInfo &CGInfo : this->FuncCGInfos) {
     DictScope D(W, "Function");
     PrintFunc(CGInfo.FunctionAddress);
     W.printNumber("Version", CGInfo.FormatVersionNumber);
@@ -8395,7 +8395,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
     W.printNumber("NumDirectCallees", CGInfo.DirectCallees.size());
     {
       ListScope DCs(W, "DirectCallees");
-      for (auto CalleePC : CGInfo.DirectCallees) {
+      for (uint64_t CalleePC : CGInfo.DirectCallees) {
         DictScope D(W);
         PrintFunc(CalleePC);
       }

>From 977c2a2d99519024ead171b9efe6a247d54b85bf Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Wed, 4 Feb 2026 00:43:56 +0000
Subject: [PATCH 20/22] Test for processing only first CG section. Get
 CGRelSection from outside lambda. Formatting.

---
 .../ELF/call-graph-info-warn-malformed.test   | 80 +++++++++++++++++++
 llvm/tools/llvm-readobj/ELFDumper.cpp         | 11 +--
 2 files changed, 86 insertions(+), 5 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index a5810616dbcde..52f7bf6513172 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -270,3 +270,83 @@ Symbols:
   - Name:  bar
   - Name:  baz
 ...
+
+## Check that the first call graph section is processed and the second call graph section is ignored.
+# RUN: yaml2obj --docnum=7 %s -o %t12
+# RUN: llvm-readobj --elf-output-style=LLVM --call-graph-info %t12 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t12 --check-prefix=LLVM-FIRST-CGSECTION --match-full-lines
+# RUN: llvm-readobj --elf-output-style=JSON --pretty-print --call-graph-info %t12 2>&1 | \
+# RUN:   FileCheck %s -DFILE=%t12 --check-prefix=JSON-FIRST-CGSECTION --match-full-lines
+
+# LLVM-FIRST-CGSECTION:      CallGraph [
+# LLVM-FIRST-CGSECTION-NEXT:     Function {
+# LLVM-FIRST-CGSECTION-NEXT:       Names: [foo]
+# LLVM-FIRST-CGSECTION-NEXT:       Address: 0x1790
+# LLVM-FIRST-CGSECTION-NEXT:       Version: 0
+# LLVM-FIRST-CGSECTION-NEXT:       IsIndirectTarget: Yes
+# LLVM-FIRST-CGSECTION-NEXT:       TypeId: 0x3ECBEEF531F74424
+# LLVM-FIRST-CGSECTION-NEXT:       NumDirectCallees: 0
+# LLVM-FIRST-CGSECTION-NEXT:       DirectCallees [
+# LLVM-FIRST-CGSECTION-NEXT:       ]
+# LLVM-FIRST-CGSECTION-NEXT:       NumIndirectTargetTypeIds: 0
+# LLVM-FIRST-CGSECTION-NEXT:       IndirectTypeIds: []
+# LLVM-FIRST-CGSECTION-NEXT:     }
+# LLVM-FIRST-CGSECTION-NEXT:    ]
+# LLVM-FIRST-CGSECTION-NOT: {{.}}
+
+# JSON-FIRST-CGSECTION:     "CallGraph": [
+# JSON-FIRST-CGSECTION-NEXT:      {
+# JSON-FIRST-CGSECTION-NEXT:        "Function": {
+# JSON-FIRST-CGSECTION-NEXT:          "Names": [
+# JSON-FIRST-CGSECTION-NEXT:            "foo"
+# JSON-FIRST-CGSECTION-NEXT:          ],
+# JSON-FIRST-CGSECTION-NEXT:          "Address": 6032,
+# JSON-FIRST-CGSECTION-NEXT:          "Version": 0,
+# JSON-FIRST-CGSECTION-NEXT:          "IsIndirectTarget": true,
+# JSON-FIRST-CGSECTION-NEXT:          "TypeId": 4524972987496481828,
+# JSON-FIRST-CGSECTION-NEXT:          "NumDirectCallees": 0,
+# JSON-FIRST-CGSECTION-NEXT:          "DirectCallees": [],
+# JSON-FIRST-CGSECTION-NEXT:          "NumIndirectTargetTypeIds": 0,
+# JSON-FIRST-CGSECTION-NEXT:          "IndirectTypeIds": []
+# JSON-FIRST-CGSECTION-NEXT:        }
+# JSON-FIRST-CGSECTION-NEXT:      }
+# JSON-FIRST-CGSECTION-NEXT:    ]
+# JSON-FIRST-CGSECTION-NEXT:   }
+# JSON-FIRST-CGSECTION-NEXT:  ]
+# JSON-FIRST-CGSECTION-NOT: {{.}}
+
+--- !ELF
+FileHeader:
+  Class:    ELFCLASS64
+  Data:     ELFDATA2LSB
+  Type:     ET_DYN
+Sections:
+  - Name:   .text
+    Type:   SHT_PROGBITS
+    Flags:  [ SHF_ALLOC, SHF_EXECINSTR ]
+  - Type:   SHT_LLVM_CALL_GRAPH
+    Flags:  [ SHF_LINK_ORDER ]
+    Link:   .text
+    ContentArray: [
+      ## --- foo ---
+      0x00, ## Version
+      0x01, ## Flags
+      0x90, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## FunctionEntryPC: 0x1790
+      0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, ## FunctionTypeID: 0x3ECBEEF531F74424
+    ]
+  ## This following second call graph section will be completely ignored.
+  - Type:   SHT_LLVM_CALL_GRAPH
+    Flags:  [ SHF_LINK_ORDER ]
+    Link:   .text
+    ContentArray: [
+      ## --- bar ---
+      0x00, ## Version
+      0x01, ## Flags
+      0xA0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ## FunctionEntryPC: 0x17A0
+      0x24, 0x44, 0xF7, 0x31, 0xF5, 0xEE, 0xCB, 0x3E, ## FunctionTypeID: 0x3ECBEEF531F74424
+    ]
+Symbols:
+  - Name:     foo
+    Type:     STT_FUNC
+    Section:  .text
+    Value:    0x1790
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 4f63cac349029..329b7dfb68e29 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -8315,6 +8315,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
                   this->FileName);
     return;
   }
+  // Process and print the first SHT_LLVM_CALL_GRAPH type section found.
   if (!this->processCallGraphSection(MapOrErr->begin()->first) ||
       this->FuncCGInfos.empty())
     return;
@@ -8324,12 +8325,12 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
   if (this->Obj.getHeader().e_type == ELF::ET_REL) {
     const Elf_Shdr *CGRelSection = MapOrErr->front().second;
     if (CGRelSection) {
+      RelocSymTab = unwrapOrError(this->FileName,
+                                  this->Obj.getSection(CGRelSection->sh_link));
       this->forEachRelocationDo(
-          *CGRelSection, [&](const Relocation<ELFT> &R, unsigned Ndx,
-                             const Elf_Shdr &Sec, const Elf_Shdr *SymTab) {
-            RelocSymTab = SymTab;
-            Relocations.push_back(R);
-          });
+          *CGRelSection,
+          [&](const Relocation<ELFT> &R, unsigned, const Elf_Shdr &,
+              const Elf_Shdr *) { Relocations.push_back(R); });
       llvm::stable_sort(Relocations, [](const auto &LHS, const auto &RHS) {
         return LHS.Offset < RHS.Offset;
       });

>From c8539f7a08c4dc96604f9d8419a92d5b9b561c27 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Wed, 4 Feb 2026 22:33:47 +0000
Subject: [PATCH 21/22] More auto related cleanups. Remove defenisve function
 symbol name empty check.

---
 llvm/tools/llvm-readobj/ELFDumper.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 329b7dfb68e29..df3b14f3c9059 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -8328,9 +8328,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
       RelocSymTab = unwrapOrError(this->FileName,
                                   this->Obj.getSection(CGRelSection->sh_link));
       this->forEachRelocationDo(
-          *CGRelSection,
-          [&](const Relocation<ELFT> &R, unsigned, const Elf_Shdr &,
-              const Elf_Shdr *) { Relocations.push_back(R); });
+          *CGRelSection, [&](const auto &R, ...) { Relocations.push_back(R); });
       llvm::stable_sort(Relocations, [](const auto &LHS, const auto &RHS) {
         return LHS.Offset < RHS.Offset;
       });
@@ -8369,8 +8367,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
       this->reportUniqueWarning(RelSymOrErr.takeError());
       return;
     }
-    if (!RelSymOrErr->Name.empty())
-      W.printString("Name", RelSymOrErr->Name);
+    W.printString("Name", RelSymOrErr->Name);
   };
 
   auto PrintFunc = [&](uint64_t FuncPC) {

>From 6458fa59e1f938bd887df2ff030be04bebbe90d4 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Fri, 13 Feb 2026 20:12:04 +0000
Subject: [PATCH 22/22] Reword missing symbol relocation error.

---
 .../llvm-readobj/ELF/call-graph-info-warn-malformed.test  | 8 ++++----
 llvm/tools/llvm-readobj/ELFDumper.cpp                     | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
index 52f7bf6513172..1a72ea8da9b43 100644
--- a/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
+++ b/llvm/test/tools/llvm-readobj/ELF/call-graph-info-warn-malformed.test
@@ -209,10 +209,10 @@ Sections:
 # RUN:   FileCheck %s -DFILE=%t11 --check-prefixes=WARN-MISSING-INFO
 
 # WARN-MISSING-INFO: warning: '[[FILE]]': SHT_LLVM_CALL_GRAPH type section has unknown type id for 2 indirect targets
-# WARN-MISSING-INFO: warning: '[[FILE]]': unknown relocation at offset 2
-# WARN-MISSING-INFO: warning: '[[FILE]]': unknown relocation at offset 19
-# WARN-MISSING-INFO: warning: '[[FILE]]': unknown relocation at offset 29
-# WARN-MISSING-INFO: warning: '[[FILE]]': unknown relocation at offset 56
+# WARN-MISSING-INFO: warning: '[[FILE]]': missing relocation for symbol at offset 2
+# WARN-MISSING-INFO: warning: '[[FILE]]': missing relocation for symbol at offset 19
+# WARN-MISSING-INFO: warning: '[[FILE]]': missing relocation for symbol at offset 29
+# WARN-MISSING-INFO: warning: '[[FILE]]': missing relocation for symbol at offset 56
 
 --- !ELF
 FileHeader:
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index df3b14f3c9059..e124a21317e0d 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -8357,7 +8357,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
       return R.Offset == RelocOffset;
     });
     if (R == Relocations.end()) {
-      this->reportUniqueWarning("unknown relocation at offset " +
+      this->reportUniqueWarning("missing relocation for symbol at offset " +
                                 Twine(RelocOffset));
       return;
     }



More information about the llvm-commits mailing list