[llvm] [docs][llvm-readobj] Document the --call-graph-info output format (PR #227386)

Prabhu Rajasekaran via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 6 15:49:06 PDT 2026


================
@@ -16,3 +16,105 @@ Each record in the `.llvm.callgraph` section has the following binary layout:
 | Direct Callees Array                   | `uintptr_t[]` | Variable    | An array of unique direct callee entry point addresses. This field is only present if there is at least one direct callee. |
 | Number of Unique Indirect Target Type IDs| `ULEB128`     | Variable    | The number of unique indirect call target type IDs. This field is only present if there is at least one indirect target type ID. |
 | Indirect Target Type IDs Array         | `uint64_t[]`  | Variable    | An array of unique indirect call target type IDs. This field is only present if there is at least one indirect target type ID. |
+
+## Dumping with llvm-readobj
+
+`llvm-readobj --call-graph-info` prints the records of every `SHT_LLVM_CALL_GRAPH` section in a file. With `--elf-output-style=JSON`, the output is a `CallGraph` array that holds one `Function` object per record. The default `LLVM` output style prints the same fields, with addresses and type IDs in hexadecimal.
+
+In executables and shared objects, functions are identified by their addresses. In relocatable object files the address fields are not final, so each function is identified by the relocation that applies to its address field instead.
+
+### Function Object
+
+| Field                      | Type             | Description |
+| -------------------------- | ---------------- | ----------- |
+| `Names`                    | array of strings | The names of the function symbols at `Address`. Omitted if there are none. Executables and shared objects only. |
+| `Address`                  | integer          | The function entry address. On ARM, the Thumb bit is cleared. Executables and shared objects only. |
+| `Reloc`                    | object           | The relocation that applies to the function entry PC field. See below. Relocatable object files only. |
+| `Offset`                   | integer          | The offset of the function entry PC field within the section. Printed instead of `Reloc` when the relocation cannot be determined. Relocatable object files only. |
+| `Version`                  | integer          | The format version. |
+| `IsIndirectTarget`         | boolean          | Whether the function is a potential indirect call target. |
+| `TypeID`                   | integer          | The function type ID. |
+| `NumDirectCallees`         | integer          | The number of entries in `DirectCallees`. |
+| `DirectCallees`            | array of objects | One object per direct callee, identified the same way as the function: by `Names` and `Address`, or by `Reloc` or `Offset`. In executables and shared objects, each callee address is listed once. |
+| `NumIndirectTargetTypeIDs` | integer          | The number of entries in `IndirectTypeIDs`. |
+| `IndirectTypeIDs`          | array of integers | The indirect call target type IDs. |
+
+### Reloc Object
+
+| Field         | Type    | Description |
+| ------------- | ------- | ----------- |
+| `SymbolIndex` | integer | The symbol table index of the relocation's symbol, or 0 if it has none. |
+| `SymbolName`  | string  | The name that the symbol's `st_name` refers to, demangled if `--demangle` is given. Omitted if the symbol has no name, such as an `STT_SECTION` symbol. |
----------------
Prabhuk wrote:

SymbolName is now always exactly what st_name says. Rather than add a separate demangled field, we dropped --demangle from this output.

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


More information about the llvm-commits mailing list