Inspect GCC 13 LTO Objects with aarch64-linux-gnu-lto-dump
aarch64-linux-gnu-lto-dump-13 opens a link-time-optimised object and shows you the symbols, sections and call graph hiding inside it. You will compile a small AArch64 object with LTO enabled, then inspect it without linking or changing your source tree.
The route
Jump straight to the step you need, or tick off Done means at the end.
The examples target Ubuntu's installed GCC 13 cross-toolchain, where the package reports version 13.3.0-6ubuntu2~24.04.1cross1. Allow about 10 minutes if the cross-compiler is already installed.
Before you start
You need aarch64-linux-gnu-gcc-13, aarch64-linux-gnu-lto-dump-13 and a writable temporary directory. The input must be an object containing GCC LTO data, normally produced by compiling with -flto. A normal machine-code object is not a useful test input.
The tool only reads and reports information. The commands below write a source file and object under /tmp; they do not install anything, alter a service or modify the current project. Treat any existing object path as sensitive if its symbol names or embedded source details must not be disclosed.
1. Confirm the installed command
Use the versioned binary explicitly when reproducing GCC 13 behaviour. The unversioned alias currently points to it, but that can change after another cross-compiler package is installed.
$ command -v aarch64-linux-gnu-lto-dump-13
/usr/bin/aarch64-linux-gnu-lto-dump-13
$ aarch64-linux-gnu-lto-dump-13 --version
lto-dump (Debian 13.3.0-6ubuntu2~24.04.1cross1) 13.3.0
Check the binary's own option list as well:
$ aarch64-linux-gnu-lto-dump-13 -help
Usage: lto-dump [OPTION]... SUB_COMMAND [OPTION]...
Tip
In this installed build, -help also shows -callgraph. The packaged man page does not list that option, so prefer the command's help output when the local documentation and executable differ.
2. Create a disposable LTO object
This source keeps two externally visible symbols so the listing is easy to recognise. Compile it with -O2 and -flto; -c stops after object creation, so no target libraries or linker are needed.
$ cat > /tmp/lto-dump-guide.c <<'EOF'
static int square(int value) { return value * value; }
int public_value = 7;
int public_square(int value) { return square(value); }
EOF
$ aarch64-linux-gnu-gcc-13 -O2 -flto -c /tmp/lto-dump-guide.c \
-o /tmp/lto-dump-guide.o
$ file /tmp/lto-dump-guide.o
/tmp/lto-dump-guide.o: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), not stripped
Checkpoint
If file reports an ordinary relocatable object but the dump tool produces no useful LTO output, check that the compile command really included -flto and used the same GCC family as the dump tool.
3. List functions and variables
Start with -list. It prints a compact table containing type, visibility, size and name. Add -defined-only when you are investigating what the object defines rather than all symbols recorded in it.
$ aarch64-linux-gnu-lto-dump-13 -list /tmp/lto-dump-guide.o
Type Visibility Size Name
function default 3 public_square
variable default 32 public_value
$ aarch64-linux-gnu-lto-dump-13 -list -defined-only /tmp/lto-dump-guide.o
- -name-sort: gives a stable alphabetical view.
- -size-sort: finds the larger entries.
- -reverse-sort: reverses whichever order is selected.
- -demangle: add it for C++ or other mangled names.
Do not assume a size is a final machine-code size: this is an LTO representation, not a linked executable. The two list-specific switches -defined-only and -print-value belong with -list; keep the input object last so the command remains easy to audit.
4. Inspect one symbol
Once the list gives you an exact name, pass it to -symbol=. This is useful for checking whether a function is defined, available and called before you inspect a larger dump.
$ aarch64-linux-gnu-lto-dump-13 -symbol=public_square /tmp/lto-dump-guide.o
public_square/2 (public_square)
Type: function definition analyzed
Visibility: externally_visible semantic_interposition public
Availability: available
Unit id: 1
Calls:
Symbol: public_square
The exact flags, counts and blank lines depend on the object and optimisation decisions. If the name is not present, go back to -list rather than guessing a compiler-generated name.
5. Inspect LTO sections and aggregate statistics
Use -objects to see the LTO object name and the sections stored inside it. This is the quickest way to confirm that the input contains GCC's .gnu.lto_* data.
$ aarch64-linux-gnu-lto-dump-13 -objects /tmp/lto-dump-guide.o
LTO Object Name: /tmp/lto-dump-guide.o
No. Offset Size Section Name
1 64 15 .gnu.lto_.profile.7acb766ff11bff67
9 272 249 .gnu.lto_public_square.2.7acb766ff11bff67
Hashes, offsets and sizes vary, so verify the section names and the input path rather than copying these numbers into a test. For a summary of the internal representation, try -type-stats, -tree-stats or -gimple-stats. They report statistics; they do not rewrite the object.
$ aarch64-linux-gnu-lto-dump-13 -type-stats /tmp/lto-dump-guide.o
Type Frequency Percentage
function_type 1 100.00
6. Capture or compare output safely
Redirect output to a new file when comparing two compiler builds. This is ordinary user-level work. Avoid overwriting the original object, and do not feed untrusted objects to a toolchain you are using for a privileged build.
$ aarch64-linux-gnu-lto-dump-13 -list -name-sort \
/tmp/lto-dump-guide.o > /tmp/lto-dump-guide.list
$ diff -u /tmp/lto-dump-guide.list /tmp/another-build.list
The tool does not have an undo operation because its normal action is read-only. To remove only the disposable files created here after checking them, run rm -- /tmp/lto-dump-guide.c /tmp/lto-dump-guide.o /tmp/lto-dump-guide.list. Do not substitute a wildcard or a directory in that cleanup command.
Common traps
- No useful symbols: the object may not have been compiled with
-flto, or it may have been produced by an incompatible GCC version. Rebuild a small object with the versioned cross-compiler. - Unknown option: run
-help. The local GCC 13 executable exposes-callgraph, while the installed man page is older in that detail. - Unknown symbol: names are exact. List first, then copy the reported name into
-symbol=; C++ names may require-demanglefor readable output. - Unexpected output volume: use one focused mode at a time and redirect large dumps to a file. The statistics and object views can be much larger on production objects.
Done means
- Tool confirmed: you confirmed the GCC 13 dump tool and its live option list.
- Object built: you produced an AArch64 LTO object with
-flto. - Symbols checked: you listed symbols and inspected one exact symbol name.
- Sections verified: you verified the presence of
.gnu.lto_*sections with-objects. - Stable vs variable: you can distinguish stable checks, such as names and section prefixes, from variable offsets and optimisation statistics.
- Cleanup known: you know the temporary files to remove and have not changed a service or persistent build configuration.