LinuxCommandLibrary

c++filt

Demangle C++ symbol names

SYNOPSIS

c++filt [-_ahi-lnorsw] [-m FORMAT] [--help] [--strip-underlying] [--no-strip-underlying] [-j | --java] [-V | --verbose] [--] [symbol ...]

PARAMETERS

-h, --help
    Display usage summary and exit.


-V, --version
    Print version information and exit.


-_, --strip-underlying
    Strip underlying type info from demangled names.


--no-strip-underlying
    Keep underlying type info (default).


-m FORMAT, --format=FORMAT
    Use specific demangling format: auto, gnu-v3, gnu-v2, gnu, lucid, arm, hp, hp-acc, sun, gabi++, java, gnat.


-a, --anonymous
    Display anonymous namespace as (anonymous namespace).


-i, --implements
    Show implementation info for virtual tables.


-l, --long
    Long format with detailed types.


-n
    No demangling; pass through unchanged.


-o
    Treat as old-style C++ mangling.


-r
    Append return type to function names.


-s
    Don't display source file info.


-w
    Suppress constructor/destructor _MOD_W mangling.


-j, --java
    Use Java demangling format.


-v, --verbose
    Verbose output with mangling details.


--
    End of options; treat rest as symbols.


DESCRIPTION

c++filt is a utility from the GNU binutils package that converts mangled C++ (and Java) symbol names into their human-readable form. C++ compilers mangle names to encode type information, overloading, and namespaces, producing cryptic strings like _Z3foov. Piping output from tools like nm, objdump, or gdb through c++filt makes debugging and analysis easier.

It supports the GNU v3 ABI by default but handles older ARM, Sun, Lucid, and Java formats via options. When no symbols are provided, it reads from stdin, making it ideal for filtering toolchain output. Verbose mode shows mangling details, aiding reverse engineering or compatibility checks.

Common use: nm -C executable uses it internally, but direct invocation allows customization. It's lightweight, fast, and essential for C++ development on Linux/Unix systems.

CAVEATS

May not perfectly demangle non-GNU compilers (e.g., MSVC). Relies on stdin if no args; use -- for symbols starting with -. Limited to supported formats.

COMMON USAGE

Demangle all symbols: nm file.o | c++filt
With types: objdump -t | c++filt -l
Specific symbol: c++filt _Z3fooiifoo(int, int)

INTEGRATION

Many tools like nm -C invoke it automatically. Use -m gnu-v3 for modern C++.

HISTORY

Introduced in early GNU binutils (1990s) alongside GCC. Evolved with C++ ABI standards; GNU v3 support added ~2002. Maintained in binutils releases, with fixes for new mangling schemes.

SEE ALSO

nm(1), objdump(1), readelf(1), addr2line(1), gdb(1)

Copied to clipboard