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

Prabhu Rajasekaran via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 15 16:50:26 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 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 7/7] 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 | ...)



More information about the llvm-commits mailing list