STRIP(1)

πŸ“¦
version 2.45.50.20251209+3.5.3build1 Β· 5 versions
, in ubuntu resolute, ubuntu stonking

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

okay bestie, pull up a chair because we're about to talk about strip, and she is that girl πŸŽ€


✨ NAME ✨

strip β€” discard symbols and other data from object files

like… she takes the receipts, the little notes, the ✨extra✨ stuff out of your object files. so slimming, so cleansing, so main character. πŸ¦‹


🌸 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...
lowkey the whole menu, right there. don't panic, we're gonna get to every single one of these β€” this is just part one, bestie, we're pacing ourselves πŸ’…

πŸ’… DESCRIPTION πŸ’…

okay so. GNU strip discards all symbols from object files β€” and by "object files" we mean the ones you hand it as objfile. 🧚

and listen, the list of object files may include archives. so like, archives can come too, they're invited, no gatekeeping here 🫢

THE RULE: at least one object file must be given. fr fr. she is not doing a vibe check on an empty list, bestie. at least one. 😭

and the part that trips people up, so let's be clear about it:

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

like… she doesn't make you a lil copy and leave the original alone. no. she goes into your file, does her thing, and that's the file now. in-place, periodt. so if you needed the original? bestie. back it up first. i'm literally begging πŸ™ˆ


that's the intro ✨ the options are coming in the next part, and there are A LOT of them, so hydrate πŸ’–

✨ OPTIONS ✨

okay bestie this is the main event, the whole buffet, every single flag you could possibly want πŸ’…

  • -F bfdname, --target=bfdname β€” treat the original objfile as if it were written in the object code format bfdname, and then rewrite it in that same format. basically "trust me, it's this format" energy ✨
  • --help β€” drops a summary of all the options strip has and then dips out. the little cheat sheet moment 🫢
  • --info β€” shows you a whole list of every architecture and object format that's actually available to you. window shopping, but for binary formats πŸ›οΈ
  • -I bfdname, --input-target=bfdname β€” treat the original objfile as a file with the object code format bfdname. that's the input side of the vibe check πŸ’–
  • -O bfdname, --output-target=bfdname β€” replace objfile with a file in the output format bfdname. so this is where you say what it's gonna become 🌈
  • -R sectionname, --remove-section=sectionname β€” yeets any section named sectionname out of the output file, on top of whatever sections were already getting removed anyway. you can say this one more than once, no cap. ⚠️ but listen: using this inappropriately can make the output file completely unusable, like actually broken, so be careful bestie 😭

the wildcard character * can go at the end of sectionname. if it's there, then every section that starts with sectionname gets removed.

oh and if the first character of sectionpattern is the exclamation point (!) then matching sections will not be removed, even if an earlier --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. iconic exemption behaviour πŸ’…

  • --keep-section=sectionpattern β€” when sections are getting removed from the output file, keep the ones that match sectionpattern. protect them πŸ₯ΊπŸ«Ά
  • --remove-relocations=sectionpattern β€” removes relocations from the output file for any section matching sectionpattern. yeah you can give this one more than once too. ⚠️ and again: using it inappropriately may make the output file unusable. wildcard characters are accepted in sectionpattern. for example:
          --remove-relocations=.text.*

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

and same deal as before: 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 otherwise cause the relocations to be removed. for 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. slay, exceptions ✨

  • --strip-section-headers β€” strips section headers. this one is specific to ELF files. it also implies --strip-all and --merge-notes, so those come along for the ride πŸŽ€
  • -s, --strip-all β€” removes all symbols. every last one. gone. πŸ’€
  • -g, -S, -d, --strip-debug β€” removes debugging symbols only. just those ones, nothing else 🌸
  • --strip-dwo β€” removes the contents of all DWARF .dwo sections, but leaves the remaining debugging sections and all symbols intact. for more info, go read the description of this option in the objcopy section. teamwork 🫢
  • --strip-unneeded β€” removes all symbols that aren't needed for relocation processing, plus the debugging symbols and sections that --strip-debug would strip anyway. combo move πŸ”₯
  • -K symbolname, --keep-symbol=symbolname β€” when symbols are getting stripped, keep the symbol symbolname even if it would normally get stripped. can be given more than once, keep 'em coming πŸ’–
  • -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. default behaviour, but make it ✨intentional✨
  • -N symbolname, --strip-symbol=symbolname β€” removes the symbol symbolname from the source file. can be given more than once, and can be combined with strip options other than -K. (not -K bestie, that one's special 🚫)
  • -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 at a time, we're not doing chaos πŸ’…
  • -p, --preserve-dates β€” preserves the access and modification dates of the file. nostalgia preservation, love that πŸŽ€
  • -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.

if binutils was configured with --enable-deterministic-archives, then this mode is on by default. it can be disabled with the -U option, below. iykyk 🧚

  • -U, --disable-deterministic-archives β€” do not operate in deterministic mode. it's the inverse of -D 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. the plot twist default 🌈

  • -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. 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. chaotic but make it precise πŸ”₯

  • -x, --discard-all β€” removes non-global symbols. bye ✌️
  • -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, retain any symbols specifying section names, which would otherwise get stripped. save the section-namers 🫢
  • --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. protect the file-name symbols too πŸ’œ
  • --only-keep-debug β€” strips a file, emptying out the contents of any sections that wouldn't be stripped by --strip-debug, and leaves 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 headers stick around 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. it's giving "receipts preserved, contents gone" 🧾

the intention is that this option gets used together with --add-gnu-debuglink to create a two part executable. one is a stripped binary that takes up less space in RAM and in a distribution, and the second is a debugging information file that's only needed if you actually need debugging abilities. 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 objcopy --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. plot twist, 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 like, one file per vibe, periodt ⚠️

  • --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. πŸ”Œ

if --plugin isn't 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's sufficient to just copy the newest one. no cap, newest one is enough πŸ’…

  • -V, --version β€” shows the version number for strip. the "who am i" moment πŸŽ€
  • -v, --verbose β€” verbose output: lists all object files modified. in the case of archives, strip -v lists all members of the archive. so chatty, we love her πŸ—£οΈ
  • @file β€” reads command-line options from file. the options read are inserted in place of the original @file option. if file doesn't 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 can be included in an option by surrounding the entire option in either single or double quotes. any character (including a backslash) can 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 plug 🫢


Copyright (c) 1991-2025 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 πŸ’– this is binutils-2.45.50, dated 2026-01-13, and it's the STRIP(1) manual. go forth and strip responsibly, mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from