STRIP(1)

πŸ“¦ version 2.47, in arch rolling

πŸ’… STRIP(1) β€” GNU Development Tools ✨

okay bestie, gather round, because strip is one of those tools that's lowkey iconic once you get what it's doing. this is the STRIP(1) page from GNU Development Tools, and yes we're reading the whole thing together, no skipping 🫢


✨ NAME ✨

strip β€” discards symbols and other data from object files, fr fr.


πŸŽ€ SYNOPSIS πŸŽ€

like, here's the whole vibe, exactly as written:

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...

no cap, that's a lot of flags, and we'll get to every single one. but first, the concept πŸ’–


🌸 DESCRIPTION 🌸

so. GNU strip discards all symbols from object files, aka the objfiles you hand it. literally all of them, by default. the way that it just... takes them out. gone. not invited to the function anymore πŸ’€

the list of object files you give it may include archives β€” yes, like .a files, it's not scared of those.

heads up bestie: at least one object file must be given. like, you can't just run it on vibes alone. it needs something to strip. an empty invocation is giving "party with no guests" and it will not fly πŸ™ˆ

and here's the part that trips people up, so pay attention πŸ‘‘

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

read that again. it's in-place. it edits your actual files, not a lil copy sitting next to them. so maybe, idk, have a backup if you're feeling fragile? because there is no "oh it made a new file" safety net here, it's giving main character energy and it's taking your originals with it 😭

so like, the whole personality of this tool? it eats symbols. it eats them in place. it needs at least one objfile to feast on, archives welcome. periodt. πŸ¦‹


and yeah, the options are right there next, all 40-ish of them, so let's keep going ✨

✨ OPTIONS ✨

Okay bestie, this is the part where it gets iconic. Every single flag, no skips, let's go πŸ’…

  • -F bfdname, --target=bfdname β€” treats the original objfile like it's chillin' in the object code format bfdname, and then rewrites it in that very same format. Same in, same out, just fresher ✨
  • --help β€” pops up a little summary of all the options strip has and then dips. That's it, that's the whole vibe.
  • --info β€” shows you a list of all the architectures and object formats available. Like a menu, but for object formats πŸ“
  • -I bfdname, --input-target=bfdname β€” treats the original objfile as a file with object code format bfdname. Input side only, she's just reading.
  • -O bfdname, --output-target=bfdname β€” replaces objfile with a file in the output format bfdname. Now that's a glow-up πŸ”₯
  • -R sectionname, --remove-section=sectionname β€” removes any section named sectionname from the output file, on top of whatever sections would've gotten removed anyway. You can drop this option more than once, she's flexible. ⚠️ Lowkey warning though: using this inappropriately can make the output file unusable. The wildcard character * can go at the end of sectionname β€” if it's there, then any section starting with sectionname gets removed.

And here's the cute part: 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 otherwise remove it. Example time:

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

will remove all sections matching the pattern '.text.*', but will not remove the section '.text.foo'. The ! is like "no thank u bestie, not this one" πŸ™ˆ

  • --keep-section=sectionpattern β€” when removing sections from the output file, keeps the sections that match sectionpattern. Protective queen behavior πŸ’–
  • --remove-relocations=sectionpattern β€” removes relocations from the output file for any section matching sectionpattern. Can be given more than once. ⚠️ And again, using this inappropriately may make the output file unusable β€” no cap. Wildcard characters are accepted in sectionpattern. For example:
          --remove-relocations=.text.*

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

Same ! energy as before: if the first character of sectionpattern is the exclamation point (!) then matching sections will not have their relocation removed, even if an earlier use of --remove-relocations on the same command line would otherwise cause 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'. Protected. Cherished. 🫢

  • --strip-section-headers β€” strips section headers. ✨ But she's picky: this option is specific to ELF files, and it implies --strip-all and --merge-notes.
  • -s, --strip-all β€” removes all symbols. Everything. Gone. Main character energy, zero attachment πŸ’€
  • -g, -S, -d, --strip-debug β€” removes debugging symbols only. Gentle. Selective. πŸŽ€
  • --strip-dwo β€” removes the contents of all DWARF .dwo sections, leaving the remaining debugging sections and all symbols intact. For the full description of this option, go check the objcopy section, she explains it better over there.
  • --strip-unneeded β€” removes all symbols that aren't needed for relocation processing, plus the debugging symbols and sections that --strip-debug strips. Double cleanse 🧚
  • -K symbolname, --keep-symbol=symbolname β€” when stripping symbols, keeps symbolname even if it would normally get stripped. Can be given more than once. Protect your faves πŸ’œ
  • -M, --merge-notes, --no-merge-notes β€” for ELF files, attempt (or don't attempt) to reduce the size of any SHT_NOTE type sections by removing duplicate notes. The default is to attempt this reduction unless stripping debug or DWO information. She tries by default, okay?
  • -N symbolname, --strip-symbol=symbolname β€” removes symbol symbolname from the source file. Can be given more than once, and can be combined with strip options other than -K. Bye bestie πŸ‘‹
  • -o file β€” puts the stripped output in file instead of replacing the existing file. When you use this argument, only one objfile argument may be specified. One. Singular. Periodt.
  • -p, --preserve-dates β€” preserves the access and modification dates of the file. Timestamps stay flawless 🌸
  • -D, --enable-deterministic-archives β€” operates in deterministic mode. When copying archive members and writing the archive index, it uses zero for UIDs, GIDs, timestamps, and uses consistent file modes for all files. Very "everything matches on purpose" of her.

If binutils was configured with --enable-deterministic-archives, then this mode is on by default. You can disable it with the -U option, right below πŸ‘‡

  • -U, --disable-deterministic-archives β€” does not operate in deterministic mode. It's literally the inverse of the -D option above: when copying archive members and writing the archive index, it uses their actual UID, GID, timestamp, and file mode values. Raw, unfiltered, no edits πŸ“Έ

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

  • -w, --wildcard β€” permits 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. And if the first character of the symbol name is the exclamation point (!) then the sense of the switch is reversed for that symbol. 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". Sneaky little ! doing the most 😭

  • -x, --discard-all β€” removes non-global symbols.
  • -X, --discard-locals β€” removes compiler-generated local symbols. (These usually start with L or .)
  • --keep-section-symbols β€” when stripping a file, maybe with --strip-debug or --strip-unneeded, retains any symbols specifying section names, which would otherwise get stripped. Save the section name girlies πŸŽ€
  • --keep-file-symbols β€” when stripping a file, maybe with --strip-debug or --strip-unneeded, retains any symbols specifying source file names, which would otherwise get stripped. Same energy, different symbol.
  • --only-keep-debug β€” strips a file, emptying the contents of any sections that wouldn't 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. πŸ‘‘

Quick note β€” the section headers of the stripped sections are preserved, including their sizes, but the contents of the section are discarded. The section headers stay so other tools can match up the debuginfo file with the real executable, even if that executable has been relocated to a different address space. iykyk.

The intention is that this option gets used alongside --add-gnu-debuglink to create a two-part executable. One: a stripped binary that takes up less space in RAM and in a distribution. Two: a debugging information file that's only needed if you actually need debugging abilities. The suggested procedure to create these files is:

  1. Link the executable as normal. Assuming it's 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 πŸ’…

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. One at a time, bestie 😭
  • --plugin name β€” loads 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. Gatekept, but fairly.

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. First come, first served πŸ’–

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. Newest = best, obviously 🌈

  • -V, --version β€” shows the version number for strip. Know your queen's era ⭐
  • -v, --verbose β€” verbose output: lists all object files modified. In the case of archives, strip -v lists all members of the archive. She's a talker, we love that πŸ¦‹
  • @file β€” reads command-line options from file. The options read are inserted in place of the original @file option. If file does not exist, or can't be read, then the option is 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. It's files all the way down πŸ˜­πŸŒ€


🌸 SEE ALSO 🌸

The Info entries for binutils. That's it, that's the whole list, go read those, they're good for you 🫢


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 ate that πŸ’…βœ¨ This lil masterpiece is from binutils-2.47, dated 2026-08-31 β€” go forth and strip responsibly, mwah πŸ«ΆπŸ’–

πŸ“¦ where this page comes from