LLVM-SYMBOLIZER(1)
π NAME π
llvm-symbolizer β bestie, it turns addresses into source code locations β¨
πΈ SYNOPSIS πΈ
llvm-symbolizer [options] [addresses...]
π DESCRIPTION π
okay so. llvm-symbolizer reads object file names and addresses from the command-line and prints the corresponding source code locations to standard output. no cap, that's literally its whole job and it eats π
if you don't specify any address on the command-line, it reads the addresses from standard input instead. and if you didn't specify an object file on the command-line but you did give addresses β or if at any point an input value isn't recognized β then the input just gets echoed straight to the output. yeah. it just hands it back. iconic behaviour honestly π
a positional argument or a standard input value can be preceded by "DATA" or "CODE" to say "hey, symbolize this as data" or "symbolize this as executable code" respectively. if you don't say either one, "CODE" is assumed. DATA gets symbolized as address and symbol size rather than line number β that's the whole difference, periodt.
object files can be specified together with the addresses, either on standard input or as positional arguments on the command-line, following any "DATA" or "CODE" prefix. π«Ά
one more thing and it's important: llvm-symbolizer parses options from the environment variable LLVM_SYMBOLIZER_OPTS after it parses options from the command line. LLVM_SYMBOLIZER_OPTS is primarily useful for supplementing the command-line options when llvm-symbolizer is invoked by another program or runtime. so if something's acting weird, check your env, bestie π
π EXAMPLES π
all of the following examples use the same two source files as input. they use a mixture of C-style and C++-style linkage to illustrate how these names are printed differently (see --demangle). chef's kiss setup tbh π
// test.h
extern "C" inline int foz() {
return 1234;
}
// test.cpp
#include "test.h"
int bar=42;
int foo() {
return bar;
}
int baz() {
volatile int k = 42;
return foz() + k;
}
int main() {
return foo() + baz();
}
these files are built as follows:
$ clang -g test.cpp -o test.elf
$ clang -g -O2 test.cpp -o inlined.elf
β Example 1 - addresses and object on command-line
$ llvm-symbolizer --obj=test.elf 0x4004d0 0x400490
foz
/tmp/test.h:1:0
baz()
/tmp/test.cpp:11:0
β Example 2 - addresses on standard input
$ cat addr.txt
0x4004a0
0x400490
0x4004d0
$ llvm-symbolizer --obj=test.elf < addr.txt
main
/tmp/test.cpp:15:0
baz()
/tmp/test.cpp:11:0
foz
/tmp/./test.h:1:0
β Example 3 - object specified with address
$ llvm-symbolizer "test.elf 0x400490" "inlined.elf 0x400480"
baz()
/tmp/test.cpp:11:0
foo()
/tmp/test.cpp:8:10
$ cat addr2.txt
test.elf 0x4004a0
inlined.elf 0x400480
$ llvm-symbolizer < addr2.txt
main
/tmp/test.cpp:15:0
foo()
/tmp/test.cpp:8:10
β Example 4 - CODE and DATA prefixes
$ llvm-symbolizer --obj=test.elf "CODE 0x400490" "DATA 0x601028"
baz()
/tmp/test.cpp:11:0
bar
6295592 4
$ cat addr3.txt
CODE test.elf 0x4004a0
DATA inlined.elf 0x601028
$ llvm-symbolizer < addr3.txt
main
/tmp/test.cpp:15:0
bar
6295592 4
β Example 5 - path-style options
this example uses the same source file as above, but the source file's full path is /tmp/foo/test.cpp and is compiled as follows. the first case shows the default absolute path, the second --basenames, and the third shows --relativenames. π¦
$ pwd
/tmp
$ clang -g foo/test.cpp -o test.elf
$ llvm-symbolizer --obj=test.elf 0x4004a0
main
/tmp/foo/test.cpp:15:0
$ llvm-symbolizer --obj=test.elf 0x4004a0 --basenames
main
test.cpp:15:0
$ llvm-symbolizer --obj=test.elf 0x4004a0 --relativenames
main
foo/test.cpp:15:0
β¨ OPTIONS β¨
--adjust-vma <offset>β adds the specified offset to object file addresses when it's doing lookups. basically it lets you do lookups as if the object had been relocated by that offset. π§--basenames,-sβ prints just the file's name, no directories, instead of the absolute path. keep it short n sweet π--relativenamesβ prints the file's path relative to the compilation directory instead of the absolute path. heads up: if the command-line to the compiler included the full path, this ends up being the same as the default. iykyk πΈ--demangle,-Cβ prints demangled function names, if the names are mangled (like, the mangled name_Z3bazvbecomesbaz(), whilst the non-mangled namefozis printed as is). defaults totrue. slay β¨--dwp <path>β use the specified DWP file at<path>for any CUs that have split DWARF debug data.--fallback-debug-path <path>β when a separate file contains debug data and is referenced by a GNU debug link section, use the specified path as a basis for locating the debug data if it can't be found relative to the object. the backup plan, bestie π«Ά--functions [=<none|short|linkage>],-fβ specifies the way function names are printed: omit the function name, print the short function name, or print the full linkage name, respectively. defaults tolinkage.--help,-hβ show help and usage for this command. classic π--help-listβ show help and usage for this command without grouping the options into categories. chaos mode, love that for us.--inlining,--inlines,-iβ if a source code location is in an inlined function, prints all the inlined frames. defaults totrue. we love transparency π--no-demangleβ don't print demangled function names. the opposite of--demangle, obviously π--obj <path>,--exe,-eβ path to the object file to be symbolized. if you pass-it reads the object directly from the standard input stream. cute π--output-style <LLVM|GNU>β specify the preferred output style. defaults toLLVM. when the output style is set toGNU, the tool follows the style of GNU'saddr2line. the differences from the LLVM style are:- it does not print the column of a source code location.
- it does not add an empty line after the report for an address.
- it does not replace the name of an inlined function with the name of the topmost caller when inlined frames are not shown and
--use-symbol-tableis on. - it does print an address's debug-data discriminator when it's non-zero. one way to produce discriminators is to compile with clang's
-fdebug-info-for-profiling.
$ llvm-symbolizer --obj=inlined.elf 0x4004be 0x400486 -p
baz() at /tmp/test.cpp:11:18
(inlined by) main at /tmp/test.cpp:15:0
foo() at /tmp/test.cpp:6:3
$ llvm-symbolizer --output-style=LLVM --obj=inlined.elf 0x4004be 0x400486 -p -i=0
main at /tmp/test.cpp:11:18
foo() at /tmp/test.cpp:6:3
$ llvm-symbolizer --output-style=GNU --obj=inlined.elf 0x4004be 0x400486 -p -i=0
baz() at /tmp/test.cpp:11
foo() at /tmp/test.cpp:6
$ clang -g -fdebug-info-for-profiling test.cpp -o profiling.elf
$ llvm-symbolizer --output-style=GNU --obj=profiling.elf 0x401167 -p -i=0
main at /tmp/test.cpp:15 (discriminator 2)
--pretty-print,-pβ print human readable output. if--inliningis specified, the enclosing scope is prefixed by(inlined by). so pretty π
$ llvm-symbolizer --obj=inlined.elf 0x4004be --inlining --pretty-print
baz() at /tmp/test.cpp:11:18
(inlined by) main at /tmp/test.cpp:15:0
--print-address,--addresses,-aβ print the address before the source code location. defaults tofalse. β¨
$ llvm-symbolizer --obj=inlined.elf --print-address 0x4004be
0x4004be
baz()
/tmp/test.cpp:11:18
main
/tmp/test.cpp:15:0
$ llvm-symbolizer --obj=inlined.elf 0x4004be --pretty-print --print-address
0x4004be: baz() at /tmp/test.cpp:11:18
(inlined by) main at /tmp/test.cpp:15:0
--print-source-context-lines <N>β printNlines of source context for each symbolized address. it's giving "show me the receipts" π₯
$ llvm-symbolizer --obj=test.elf 0x400490 --print-source-context-lines=2
baz()
/tmp/test.cpp:11:0
10 : volatile int k = 42;
11 >: return foz() + k;
12 : }
--use-symbol-tableβ prefer function names stored in the symbol table to function names in debug info sections. defaults totrue.--verboseβ print verbose line and column information. spill the tea β
$ llvm-symbolizer --obj=inlined.elf --verbose 0x4004be
baz()
Filename: /tmp/test.cpp
Function start line: 9
Line: 11
Column: 18
main
Filename: /tmp/test.cpp
Function start line: 14
Line: 15
Column: 0
--versionβ print version information for the tool. π@<FILE>β read command-line options from response file<FILE>.
π¦ MACH-O SPECIFIC OPTIONS π¦
--default-arch <arch>β if a binary contains object files for multiple architectures (like, it's a Mach-O universal binary), symbolize the object file for a given architecture. you can also specify the architecture by writingbinary_name:arch_namein the input (see the example below). if the architecture is not specified in either way, the address will not be symbolized. defaults to empty string. rude of it but ok π
$ cat addr.txt
/tmp/mach_universal_binary:i386 0x1f84
/tmp/mach_universal_binary:x86_64 0x100000f24
$ llvm-symbolizer < addr.txt
_main
/tmp/source_i386.cc:8
_main
/tmp/source_x86_64.cc:8
--dsym-hint <path/to/file.dSYM>β if the debug info for a binary isn't present in the default location, look for the debug info at the.dSYMpath provided via this option. this flag can be used multiple times. stack 'em up π
π EXIT STATUS π
llvm-symbolizer returns 0. any other exit codes imply an internal program error. so if you get something else, it's not you, it's the program bestie π
π SEE ALSO π
π AUTHOR π
maintained by the LLVM Team (https://llvm.org/). absolute icons, no notes β¨
π COPYRIGHT π
2003-2024, LLVM Project
and that's the whole page, bestie β this was the llvm-symbolizer manual, section 11, dated 2024-07-18, brought to you by the LLVM crew. go symbolize something cute ππ¦β¨
π¦ where this page comes from
- fedora 43: llvm11 11.1.0-14.fc41 Β· NCSA
- fedora 43: llvm11 11.1.0-14.fc41 Β· NCSA
- fedora 44: llvm11 11.1.0-14.fc41 Β· NCSA
- fedora 44: llvm11 11.1.0-14.fc41 Β· NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms