LinuxCommandLibrary

strip

Remove symbols from object files

TLDR

Strip all symbols from a file (in place)

$ strip [path/to/file]
copy
Strip and save to output file
$ strip [path/to/input] -o [path/to/output]
copy
Strip debug symbols only
$ strip -d [path/to/file.o]
copy
Strip unneeded symbols
$ strip --strip-unneeded [path/to/file]
copy
Keep specific symbols
$ strip -K [symbol_name] [path/to/file]
copy
Remove specific section
$ strip -R [section_name] [path/to/file]
copy
Keep only debug information
$ strip --only-keep-debug [path/to/file]
copy

SYNOPSIS

strip [OPTIONS] objfile...

DESCRIPTION

strip removes symbols and other data from object files and executables, reducing file size and making reverse engineering more difficult. It modifies files in-place by default. Archives (.a files) can also be stripped.
Stripping debug symbols is common for release builds to reduce binary size while retaining functionality. The --only-keep-debug option creates separate debug files that can be used with debuggers while keeping production binaries small.

PARAMETERS

-s, --strip-all

Remove all symbols (default)
-g, -S, -d, --strip-debug
Remove debugging symbols only
--strip-unneeded
Remove unneeded symbols for relocation
--only-keep-debug
Keep only debugging sections
-K, --keep-symbol name
Preserve specific symbol (repeatable)
-N, --strip-symbol name
Remove specific symbol (repeatable)
-R, --remove-section name
Remove named section (wildcards allowed)
--keep-section pattern
Retain matching sections
-x, --discard-all
Remove all non-global symbols
-X, --discard-locals
Remove compiler-generated local symbols
-o file
Write output to file (single input only)
-p, --preserve-dates
Keep access/modification timestamps
-D, --enable-deterministic-archives
Use zero for UID/GID/timestamps in archives
-w, --wildcard
Allow regex in symbol names
-v, --verbose
List processed files
--help
Display help
--version
Display version

CAVEATS

Stripping modifies files in place; back up originals if needed. Over-stripping can break dynamic linking or debugging capabilities. Use --strip-debug for libraries that may be linked against. Static analysis and debugging become difficult after stripping.

HISTORY

strip is part of GNU binutils, the collection of binary tools maintained by the Free Software Foundation. The command originated in early Unix at Bell Labs in the 1970s as a way to reduce executable size on systems with limited storage. GNU binutils provides the modern implementation used on Linux.

SEE ALSO

objcopy(1), objdump(1), readelf(1), nm(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community