STRIP(1)
π strip(1) β GNU Development Tools, section 1 π
okay bestie, buckle up, because <rainbow>strip</rainbow> is one of those commands that will absolutely eat your files if you don't vibe with it first. this page lives in the GNU Development Tools manual, section 1. let's get into it π«Ά
β¨ NAME β¨
strip β discard symbols and other data from object files
like, it takes your chunky little object files and declutters them. symbol-free. minimal. clean girl aesthetic π
β¨ 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...
yes, that's a lot of brackets. no, you cannot skip them. every single one of those flags gets its own moment later, i promise πΈ
β¨ DESCRIPTION β¨
GNU strip discards all symbols from object files, and those object files go by the name objfile. π
and the list of object files you hand it? it's not picky β that list may include archives. archives are welcome here, we don't gatekeep π§
β οΈ but here's the rule: at least one object file must be given. zero objfiles = strip has nothing to work with and is gonna be very dramatic about it π
the other thing you absolutely need to internalize, bestie, is this β strip modifies the files named in its argument rather than writing modified copies under different names.
translation: it edits your files IN PLACE. it does not make a cute little backup copy with a new name and leave your originals chilling. the file you passed in is the file that gets changed. periodt β¨
so like. maybe keep a backup. i'm just saying. π
okay so that's the whole vibe of what strip is β the symbol-discarding, in-place-editing declutter queen π
but we are NOT done, because all those flags in the synopsis? they each have lore. every target name, every keep-symbol, every deterministic-archive toggle, the plugin stuff, the verbose stuff, the version and help and info stuff β it's all coming. more parts follow, so don't go anywhere π
β¨ OPTIONS β¨
okay bestie, buckle up π this is the big list of every little switch strip will actually listen to. take your time, there's a lot, and we're going through all of it β no skipping, no cap.
-F bfdname,--target=bfdnameβ tellsstripto treat the original objfile as a file with the object code format bfdname, and then rewrite it in that same format. π--helpβ shows you a summary of the optionsstriptakes, then peaces out. that's it, that's the whole job. β¨--infoβ displays a list showing all the architectures and object formats that are available. like a lil menu of what you can play with π-I bfdname,--input-target=bfdnameβ treat the original objfile as a file with the object code format bfdname. (input side only this time, not both π)-O bfdname,--output-target=bfdnameβ replace objfile with a file in the output format bfdname.-R sectionname,--remove-section=sectionnameβ yeets any section named sectionname from the output file, in addition to whatever sections would otherwise get removed. may be given more than once. β οΈ but note: using this option inappropriately may make the output file unusable. you have been warned, bestie.
you can also slap a wildcard character * at the end of sectionname β if you do, then any section starting with sectionname will be removed.
and here's the spicy 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. like:
--remove-section=.text.* --remove-section=!.text.foo
that removes all sections matching the pattern .text.*, but will not remove the section .text.foo. see what she did there π
--keep-section=sectionpatternβ when removing sections from the output file, keep the sections that match sectionpattern. inverse energy, love that πΈ--remove-relocations=sectionpatternβ removes relocations from the output file for any section matching sectionpattern. may be given more than once. β οΈ and again β using this inappropriately may make the output file unusable. wildcard characters are accepted in sectionpattern. for example:
--remove-relocations=.text.*
which removes the relocations for all sections matching the pattern .text.*.
same ! trick 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 them to be removed. for example:
--remove-relocations=.text.* --remove-relocations=!.text.foo
removes all relocations for sections matching the pattern .text.*, but will not remove relocations for the section .text.foo. π«Ά
--strip-section-headersβ strips section headers. this one is specific to ELF files. implies--strip-alland--merge-notes.-s,--strip-allβ remove all symbols. every last one, bye π-g,-S,-d,--strip-debugβ remove debugging symbols only. just the debug stuff, nothing else.--strip-dwoβ removes the contents of all DWARF.dwosections, leaving the remaining debugging sections and all symbols intact. π§ for the full tea, see the description of this option in theobjcopysection.--strip-unneededβ removes all symbols that are not needed for relocation processing, on top of the debugging symbols and sections stripped by--strip-debug.-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.-M,--merge-notes,--no-merge-notesβ for ELF files, attempt (or do not attempt, depending which one you pick) to reduce the size of anySHT_NOTEtype 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β removes 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β puts the stripped output in file, rather than replacing the existing file. π when this argument is used, only one objfile argument may be specified.-p,--preserve-datesβ preserves the access and modification dates of the file. time traveler behavior, honestly β°-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 π
-U,--disable-deterministic-archivesβ do not operate in deterministic mode. it's the inverse of the-Doption 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β 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". sneaky, iconic π
-x,--discard-allβ removes non-global symbols.-X,--discard-localsβ removes compiler-generated local symbols. (these usually start withLor.)--keep-section-symbolsβ when stripping a file, perhaps with--strip-debugor--strip-unneeded, retain any symbols specifying section names, which would otherwise get stripped.--keep-file-symbolsβ when stripping a file, perhaps with--strip-debugor--strip-unneeded, retain any symbols specifying source file names, which would otherwise get stripped.--only-keep-debugβ strips a file, emptying the contents of any sections that would not be stripped by--strip-debugand 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 preserved 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.
the intention is that this option will be used in conjunction with --add-gnu-debuglink to create a two part executable. one is a stripped binary which occupies less space in RAM and in a distribution, and the second is a debugging information file which is only needed if debugging abilities are required. the suggested procedure to create these files is as follows:
- Link the executable as normal. assuming that it is called
"foo"then... - Run
"objcopy --only-keep-debug foo foo.dbg"to create a file containing the debugging info. - Run
"strip --strip-debug foo"to create a stripped executable. - 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:
- Link the executable as normal.
- Copy
"foo"to"foo.full". - Run
"strip --strip-debug foo". - 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.
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.
--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 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β shows the version number forstrip.-v,--verboseβ verbose output: lists all object files modified. in the case of archives,strip -vlists all members of the archive. π@fileβ reads command-line options from file. the options read are inserted in place of the original@fileoption. 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
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 β¨ this one shipped as part of binutils-2.47, dated 2026-09-19, and it's page STRIP(1) of the manual. now go forth and strip responsibly π π
π¦ where this page comes from
- ubuntu stonking: binutils-sh-elf 2.47+3build2 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms