STRIP(1)

๐Ÿ’… STRIP(1) โ€” GNU Development Tools ๐ŸŒธ

okay bestie, welcome to the strip page, we're doing this in parts so buckle up ๐Ÿ’–


โœจ NAME โœจ

strip โ€” the icon that discards symbols and other data from object files, no cap ๐Ÿ—‘๏ธโœจ


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

strip [-F bfdname |--target=bfdname]
      [-I bfdname |--input-target=bfdname]
      [-O bfdname |--output-target=bfdname]
      [-s|--strip-all]
      [-S|-g|-d|--strip-debug]
      [--strip-dwo]
      [-K symbolname|--keep-symbol=symbolname]
      [-M|--merge-notes][--no-merge-notes]
      [-N symbolname |--strip-symbol=symbolname]
      [-w|--wildcard]
      [-x|--discard-all] [-X |--discard-locals]
      [-R sectionname |--remove-section=sectionname]
      [--keep-section=sectionpattern]
      [--remove-relocations=sectionpattern]
      [--strip-section-headers]
      [-o file] [-p|--preserve-dates]
      [-D|--enable-deterministic-archives]
      [-U|--disable-deterministic-archives]
      [--keep-section-symbols]
      [--keep-file-symbols]
      [--only-keep-debug]
      [--plugin name]
      [-v |--verbose] [-V|--version]
      [--help] [--info]
      objfile...

likeโ€ฆ look at her. so many options. she's serving options ๐Ÿ’…


๐ŸŒˆ DESCRIPTION ๐ŸŒˆ

GNU strip justโ€ฆ discards all symbols from object files, and those object files are your objfile besties. it's giving "we don't need the lore, we need the vibes" ๐Ÿงš

so basically the list of object files? it may include archives. and at least one object file must be given โ€” like, you can't just show up with nothing, that's not the move ๐Ÿ™ˆ

strip modifies the files named in its argument, rather than writing modified copies under different names.

โš ๏ธ okay this part matters, fr fr: strip doesn't make a cute little copy for you. she edits the actual files you named. in place. that's it. so if you wanted a backup, that's on you, bestie ๐Ÿ˜ญ

and that's part one, there's more coming so don't go anywhere ๐Ÿซถ

okay bestie, this is the part where we get into the actual flags ๐Ÿ’… Like, this is the whole toolkit. Read it slow, it's giving โœจreference materialโœจ.

  • -F bfdname, --target=bfdname โ€” treat the original objfile as if it were a file in the object code format bfdname, and then rewrite it right back out in that same format. Same in, same out. ๐ŸŽ€
  • --help โ€” show a lil summary of the options strip takes, then bounce. โœจ
  • --info โ€” display a list of every architecture and every object format that's available. Like a menu of your options, fr.
  • -I bfdname, --input-target=bfdname โ€” treat the original objfile as a file with the object code format bfdname. That's the "what am I reading" one ๐Ÿฆ‹
  • -O bfdname, --output-target=bfdname โ€” replace objfile with a file in the output format bfdname. That's the "what am I writing" one. Iconic duo, honestly.
  • -R sectionname, --remove-section=sectionname โ€” remove any section named sectionname from the output file, on top of whatever sections would've gotten removed anyway. You can pass this one more than once. ๐ŸŒธ
โš ๏ธ bestie, real talk: using this option inappropriately may make the output file unusable. No cap.

The wildcard character * may be given at the end of sectionname. If you do that, then any section starting with sectionname gets removed.

And here's the plot twist: if the first character of sectionpattern is the exclamation point (!), then matching sections will not be removed โ€” even if an earlier use of --remove-section on the same command line would've otherwise removed it. For example:

--remove-section=.text.* --remove-section=!.text.foo

will remove all sections matching the pattern .text.*, but will not remove the section .text.foo. Sneaky, but make it make sense ๐Ÿ˜Œ

  • --keep-section=sectionpattern โ€” when you're removing sections from the output file, keep the sections that match sectionpattern. The "actually no, not that one" flag ๐Ÿซถ
  • --remove-relocations=sectionpattern โ€” remove relocations from the output file for any section matching sectionpattern. May be given more than once. ๐Ÿ’€
โš ๏ธ again: using this option inappropriately may make the output file unusable. We're not kidding around here.

Wildcard characters are accepted in sectionpattern. For example:

--remove-relocations=.text.*

will remove the relocations for all sections matching the pattern .text.*.

And yes, the ! thing works here too: if the first character of sectionpattern is the exclamation point (!), then matching sections will not have their relocations removed โ€” even if an earlier use of --remove-relocations on the same command line would've otherwise caused the relocations to be removed. Example:

--remove-relocations=.text.* --remove-relocations=!.text.foo

will remove all relocations for sections matching the pattern .text.*, but will not remove relocations for the section .text.foo. Periodt. ๐Ÿ’…

  • --strip-section-headers โ€” strip section headers. This one is specific to ELF files. It implies --strip-all and --merge-notes. โœจ
  • -s, --strip-all โ€” remove all symbols. All of them. Gone. ๐Ÿ‘‘
  • -g, -S, -d, --strip-debug โ€” remove debugging symbols only. (yes, three whole short flags for this one vibe, slay)
  • --strip-dwo โ€” remove the contents of all DWARF .dwo sections, leaving the remaining debugging sections and all symbols intact. See the description of this option in the objcopy section for more info. ๐Ÿฆ‹
  • --strip-unneeded โ€” remove all symbols that aren't needed for relocation processing, plus the debugging symbols and sections that --strip-debug already strips. Double cleanse ๐Ÿงš
  • -K symbolname, --keep-symbol=symbolname โ€” when stripping symbols, keep the symbol symbolname even if it would normally get stripped. May be given more than once. The "not this one tho" list ๐Ÿ’–
  • -M, --merge-notes, --no-merge-notes โ€” for ELF files, attempt (or do not attempt) to shrink any SHT_NOTE type sections by removing duplicate notes. The default is to attempt this reduction โ€” unless you're stripping debug or DWO information. ๐ŸŒˆ
  • -N symbolname, --strip-symbol=symbolname โ€” remove the symbol symbolname from the source file. May be given more than once, and may be combined with strip options other than -K. โœ‚๏ธ
  • -o file โ€” put the stripped output in file, instead of replacing the existing file. Heads up: when you use this argument, only one objfile argument may be specified. ๐ŸŒธ
  • -p, --preserve-dates โ€” preserve the access and modification dates of the file. Time travel, but legal. โญ
  • -D, --enable-deterministic-archives โ€” operate in deterministic mode. When copying archive members and writing the archive index, use zero for UIDs, GIDs, timestamps, and use consistent file modes for all files. So same input = same output, every time. ๐ŸŽ€

If binutils was configured with --enable-deterministic-archives, then this mode is on by default. It can be disabled with the -U option, below. ๐Ÿ‘‡

  • -U, --disable-deterministic-archives โ€” do not operate in deterministic mode. This is the inverse of the -D option above: when copying archive members and writing the archive index, use their actual UID, GID, timestamp, and file mode values. ๐Ÿ’œ

This is the default โ€” unless binutils was configured with --enable-deterministic-archives.

  • -w, --wildcard โ€” permit regular expressions in symbolnames used in other command line options. The question mark (?), asterisk (*), backslash (\) and square brackets ([]) operators can be used anywhere in the symbol name. If the first character of the symbol name is the exclamation point (!) then the sense of the switch is reversed for that symbol. For example:
-w -K !foo -K fo*

would cause strip to only keep symbols that start with the letters "fo", but to discard the symbol "foo". Chaos but make it intentional ๐Ÿ˜ญ

  • -x, --discard-all โ€” remove non-global symbols. ๐Ÿ”ฅ
  • -X, --discard-locals โ€” remove compiler-generated local symbols. (These usually start with L or .) ๐Ÿงน
  • --keep-section-symbols โ€” when stripping a file, maybe with --strip-debug or --strip-unneeded, retain any symbols specifying section names, which would otherwise get stripped. ๐Ÿซถ
  • --keep-file-symbols โ€” when stripping a file, maybe with --strip-debug or --strip-unneeded, retain any symbols specifying source file names, which would otherwise get stripped. ๐Ÿ’–
  • --only-keep-debug โ€” strip a file, emptying the contents of any sections that would not be stripped by --strip-debug, and leaving the debugging sections intact. In ELF files, this preserves all the note sections in the output as well. ๐Ÿ‘‘
Note: the section headers of the stripped sections are preserved, including their sizes โ€” but the contents of the section are discarded. The section headers are kept so that other tools can match up the debuginfo file with the real executable, even if that executable has been relocated to a different address space. Kinda genius tbh.

The intention is that this option gets used in conjunction with --add-gnu-debuglink to create a two part executable:

  1. One is a stripped binary, which occupies less space in RAM and in a distribution.
  2. The other is a debugging information file, which is only needed if debugging abilities are required.

The suggested procedure to create these files is as follows:

  1. Link the executable as normal. Assuming that it is called "foo" then...
  2. Run "objcopy --only-keep-debug foo foo.dbg" to create a file containing the debugging info.
  3. Run "strip --strip-debug foo" to create a stripped executable.
  4. Run "objcopy --add-gnu-debuglink=foo.dbg foo" to add a link to the debugging info into the stripped executable.
Note: the choice of ".dbg" as an extension for the debug info file is arbitrary. Also the "--only-keep-debug" step is optional. You could instead do this:
  1. Link the executable as normal.
  2. Copy "foo" to "foo.full".
  3. Run "strip --strip-debug foo".
  4. Run "objcopy --add-gnu-debuglink=foo.full foo".

i.e., the file pointed to by the --add-gnu-debuglink can be the full executable. It does not have to be a file created by the --only-keep-debug switch. Flexible queen โœจ

Note: this switch is only intended for use on fully linked files. It does not make sense to use it on object files where the debugging information may be incomplete. Besides, the gnu_debuglink feature currently only supports the presence of one filename containing debugging information, not multiple filenames on a one-per-object-file basis. So don't try it, bestie ๐Ÿ™ˆ
  • --plugin name โ€” load the plugin called name to add support for extra target types. This option is only available if the toolchain has been built with plugin support enabled. ๐Ÿงš

If --plugin is not provided, but plugin support has been enabled, then strip iterates over the files in ${libdir}/bfd-plugins in alphabetic order and the first plugin that claims the object in question is used.

Please note that this plugin search directory is not the one used by ld's -plugin option. In order to make strip use the linker plugin it must be copied into the ${libdir}/bfd-plugins directory. For GCC based compilations the linker plugin is called liblto_plugin.so.0.0.0. For Clang based compilations it is called LLVMgold.so. The GCC plugin is always backwards compatible with earlier versions, so it is sufficient to just copy the newest one. ๐Ÿซถ
  • -V, --version โ€” show the version number for strip. ๐Ÿ“Œ
  • -v, --verbose โ€” verbose output: list all object files modified. In the case of archives, strip -v lists all members of the archive. So chatty of it ๐Ÿ’…
  • @file โ€” read command-line options from file. The options read are inserted in place of the original @file option. If file does not exist, or cannot be read, then the option will be treated literally, and not removed. ๐Ÿ˜ญ

Options in file are separated by whitespace. A whitespace character may be included in an option by surrounding the entire option in either single or double quotes. Any character (including a backslash) may be included by prefixing the character to be included with a backslash. The file may itself contain additional @file options; any such options will be processed recursively. ๐ŸŒ€


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

the Info entries for binutils.


Copyright (c) 1991-2026 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".


and that's the whole page bestie, you made it to the end ๐ŸŽ€ this lil masterpiece is binutils-2.47, dated 2026-08-11 โ€” go forth and strip responsibly, mwah ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: binutils 2.47-4 ยท GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-2.0-or-later AND LGPL-3.0-or-later AND GFDL-1.3 AND FSFAP
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms