Home / Alt manpages / x86_64-linux-gnu-lto-dump-13(1)

  • x86_64-linux-gnu-lto-dump-13(1)
  • User command
  • linux

Inspect GCC 13 LTO Objects with lto-dump

You will inspect a GCC link-time optimisation object, list the symbols it contains, examine its LTO sections and ask for details about one symbol. The commands are read-only: they do not rewrite the object or relink your program.

Allow about fifteen minutes if you already have an object compiled with -flto. You need the GCC 13 toolchain and a readable LTO object. The examples use Ubuntu's installed GCC 13.3.0 packages and the command x86_64-linux-gnu-lto-dump-13.

Checkpoint

This tool examines compiler intermediate data, not an ordinary executable or a normal non-LTO object. If it reports an input error, first confirm how that file was built.

1. Confirm the installed command

Start with ordinary, unprivileged checks. No sudo is needed unless the object is in a directory you cannot read:

$ command -v x86_64-linux-gnu-lto-dump-13
/usr/bin/x86_64-linux-gnu-lto-dump-13
$ dpkg-query -W -f='${Package} ${Version}\n' gcc-13 gcc-13-x86-64-linux-gnu gcc-x86-64-linux-gnu
gcc-13 13.3.0-6ubuntu2~24.04.1
gcc-13-x86-64-linux-gnu 13.3.0-6ubuntu2~24.04.1
gcc-x86-64-linux-gnu 4:13.2.0-7ubuntu1

The version shown above is the package version on the machine used for this guide. The executable does not print a useful version string for --version, so record the package version when you need reproducible diagnostics.

Ask the installed binary for its own option summary:

$ x86_64-linux-gnu-lto-dump-13 -help
Usage: lto-dump [OPTION]... SUB_COMMAND [OPTION]...

LTO dump tool command line options.

Use the target-prefixed command when you want to be explicit about the architecture. The unprefixed alias lto-dump-13 is also installed on this system.

2. Produce a small LTO object for a safe test

If you already have the object you need to inspect, skip to the next step. Otherwise create a temporary source file and compile it without elevated privileges:

$ workdir=$(mktemp -d /tmp/lto-dump-example.XXXXXX)
$ printf '%s\n' 'int answer(void) { return 42; }' > "$workdir/sample.c"
$ gcc-13 -O2 -flto -c "$workdir/sample.c" -o "$workdir/sample.o"
$ file "$workdir/sample.o"
/tmp/lto-dump-example.XXXXXX/sample.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

The random directory suffix and exact file wording vary. The useful result is a relocatable object produced with -flto. The compiler has not created a service, installed anything or changed a system setting.

Recovery

The example writes only below /tmp. Remove that temporary directory after inspection with rm -r -- "$workdir" once you have finished. Do not substitute a broad or unreviewed path into a removal command.

3. List the functions and variables

-list is the best first inspection. It prints a table with the symbol type, visibility, size and name:

$ x86_64-linux-gnu-lto-dump-13 -list "$workdir/sample.o"
Type   Visibility  Size  Name
function  default     3  answer

Real objects often contain many more entries. Use -defined-only to omit symbols that are not defined in the object, and use -demangle when the input contains C++ names. The two options are sub-options of -list:

$ x86_64-linux-gnu-lto-dump-13 -list -defined-only -demangle "$workdir/sample.o"
$ x86_64-linux-gnu-lto-dump-13 -list -name-sort "$workdir/sample.o"
$ x86_64-linux-gnu-lto-dump-13 -list -size-sort "$workdir/sample.o"
$ x86_64-linux-gnu-lto-dump-13 -list -reverse-sort "$workdir/sample.o"

Sorting changes presentation only. It does not change the object. -print-value adds initial variable values when those values are available in the dump data.

One version-specific trap is worth recording: the installed GCC 13.3.0 binary rejects -no-sort, although the installed manpage lists it. Trust the executable's help and test the exact command on the host where a script will run; do not build automation around that documented option without checking its availability.

4. Inspect one symbol in detail

Once -list gives you a name, pass it to -symbol=. Keep the value attached to the option:

$ x86_64-linux-gnu-lto-dump-13 -symbol=answer "$workdir/sample.o"
answer/0 (answer)
  Type: function definition analyzed
  Visibility: externally_visible semantic_interposition public
  References:
  Referring:
  Read from file: /tmp/lto-dump-example.XXXXXX/sample.o
  Availability: available
  Unit id: 1
  Function flags: count:1073741824 (estimated locally)
  Called by:
  Calls:
Symbol: answer

Paths, unit identifiers and estimates are input-dependent. Treat the output as compiler analysis data, not as a promise that the function will survive unchanged into the final executable. If the name is absent, rerun -list and copy an exact symbol name rather than guessing a mangled spelling.

5. See the LTO object sections

-objects reports the LTO objects and the sections stored inside them:

$ x86_64-linux-gnu-lto-dump-13 -objects "$workdir/sample.o"
    LTO Object Name: /tmp/lto-dump-example.XXXXXX/sample.o

No.    Offset    Size       Section Name

 1       64       15   .gnu.lto_.profile.983b7ac5fa8de62
 2       79       26   .gnu.lto_.icf.983b7ac5fa8de62
 3      105       22   .gnu.lto_.ipa_sra.983b7ac5fa8de62
 ...

The section names and offsets tell you what LTO data is present and where it sits in the object. They are useful when comparing compiler outputs or investigating a toolchain problem. They are not a replacement for readelf or objdump when you need general ELF headers or machine code.

6. Request statistics or a call graph

The installed command also accepts analysis subcommands for type, tree and GIMPLE statistics. For example:

$ x86_64-linux-gnu-lto-dump-13 -type-stats "$workdir/sample.o"
       Type     Frequency   Percentage

 function_type      1       100.00

On this build, -tree-stats and -gimple-stats can warn that the binary was not configured with detailed memory statistics. That warning describes a build capability; it is not evidence that the object is damaged.

-callgraph is shown by the installed help and emits Graphviz format. It is not listed in the installed manpage, so treat it as an installed-binary feature rather than a portable GCC 13 interface. Save output to a new file if you want to render it:

$ x86_64-linux-gnu-lto-dump-13 -callgraph "$workdir/sample.o" > "$workdir/callgraph.dot"
$ head -n 1 "$workdir/callgraph.dot"
digraph symtab {

Redirection with > truncates an existing destination before the command runs. Use a new path, as above, or make a deliberate backup first. If the command fails, remove only the incomplete new file; the input object remains unchanged.

7. Keep failures in proportion

A normal inspection should need no elevated privileges. If the input cannot be opened, check its path and permissions:

$ ls -l /path/to/object.o
$ test -r /path/to/object.o && echo readable

Use sudo only when that read check identifies an access requirement and your local policy permits it. Root access will not turn a non-LTO object into an LTO object. If the file is an executable or a regular object compiled without -flto, use tools intended for that format instead.

For a repeatable report, capture the package versions, the exact command, the input path and the exit status. Do not treat empty sections, missing symbols or an empty call graph as a failure without checking how the object was compiled and which subcommand you selected.

Done means

  • You confirmed the installed GCC 13 package and command path.
  • You inspected an object compiled with -flto using -list.
  • You used exact symbol names with -symbol= when deeper detail was needed.
  • You distinguished the installed binary's help from the older or broader manpage option list.
  • You kept output redirection pointed at new files and left the input object untouched.
  • You used no elevated privileges unless filesystem permissions actually required them.