STRIP(1)
π STRIP(1) β GNU Development Tools π
okay bestie, welcome to STRIP(1) from GNU Development Tools β part 1 of 2, so buckle up π
π¦ NAME π¦
strip β discard symbols and other data from object files β¨
πΈ 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...
π§ DESCRIPTION π§
So, GNU strip is literally the icon that discards all symbols from object files objfile. π
The list of object files may include archives β yes, archives are allowed, bestie π«Ά
Important vibe check: at least one object file must be given. No objfiles, no party. π
And hereβs the part that matters: strip modifies the files named in its argument, rather than writing modified copies under different names. So itβs editing the actual files you named β not making cute little renamed copies on the side. π
β¨ OPTIONS β¨
okay bestie, this is the part where we go through literally every single flag, so grab a snack π
-Fbfdname,--target=bfdname β treat the original objfile as a file with the object code format bfdname, and rewrite it in that same format. slay, one format, in and out π--helpβ show a summary of the optionsstriphas and dip. simple, iconic, no notes β¨--infoβ display a list showing all architectures and object formats available. it's giving "let me show you around" π-Ibfdname,--input-target=bfdname β treat the original objfile as a file with the object code format bfdname. that's the input's whole identity, no cap π¦-Obfdname,--output-target=bfdname β replace objfile with a file in the output format bfdname. glow-up via format change π₯-Rsectionname,--remove-section=sectionname β remove any section named sectionname from the output file, on top of whatever sections would otherwise get removed. you can give this option more than once, fr fr.
β οΈ heads up bestie: using this option inappropriately may make the output file unusable. like, genuinely π
the wildcard character * may be given at the end of sectionname. if so, then any section starting with sectionname will be removed.
and 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. 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'. the audacity of that one exception, honestly π
--keep-section=sectionpattern β when removing sections from the output file, keep the sections that match sectionpattern. the protect-this-at-all-costs flag π«Ά--remove-relocations=sectionpattern β remove relocations from the output file for any section matching sectionpattern. this option may be given more than once. and yes β using this option inappropriately may make the output file unusable. same warning, same energy π
wildcard characters are accepted in sectionpattern. for example:
--remove-relocations=.text.*
will remove the relocations for all sections matching the pattern '.text.*'.
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'. exceptions stay winning π
--strip-section-headersβ strip section headers. this one is specific to ELF files, and it implies--strip-alland--merge-notes. so it's a whole combo deal π-s,--strip-allβ remove all symbols. all of them. every last one. bye π-g,-S,-d,--strip-debugβ remove debugging symbols only. just the debug ones, we're being gentle π§--strip-dwoβ remove the contents of all DWARF.dwosections, leaving the remaining debugging sections and all symbols intact. theobjcopysection has a whole description of this option if you want more info, iykyk πΈ--strip-unneededβ remove all symbols that are not needed for relocation processing, in addition to the debugging symbols and sections stripped by--strip-debug. the overachiever flag β-Ksymbolname,--keep-symbol=symbolname β when stripping symbols, keep symbol symbolname even if it would normally get stripped. this option may be given more than once. the "not this one, she's my friend" flag π«Ά-M,--merge-notes,--no-merge-notesβ for ELF files, attempt (or do not attempt) 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. so it's lowkey on by default π-Nsymbolname,--strip-symbol=symbolname β remove symbol symbolname from the source file. this option may be given more than once, and it may be combined with strip options other than-K. so many options, so much power π-ofile β put the stripped output in file, rather than replacing the existing file. when this argument is used, only one objfile argument may be specified. one at a time, bestie π-p,--preserve-datesβ preserve the access and modification dates of the file. time travel but make it file metadata β³-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. everything identical, everything calm β¨
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-Doption above: when copying archive members and writing the archive index, use their actual UID, GID, timestamp, and file mode values. the real ones, the authentic ones π
this is the default unless binutils was configured with --enable-deterministic-archives.
-w,--wildcardβ permit regular expressions in *symbolname*s 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 correct, honestly π
-x,--discard-allβ remove non-global symbols. not everyone gets to stay π¦-X,--discard-localsβ remove compiler-generated local symbols. (these usually start withLor..) you know the ones π--keep-section-symbolsβ when stripping a file, perhaps with--strip-debugor--strip-unneeded, retain any symbols specifying section names, which would otherwise get stripped. protection squad, assemble π«Ά--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. also protected πΈ--only-keep-debugβ strip 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. it's giving "keep the lore, drop the rest" π
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. literally just the labels stay, the contents dip π
the intention is that this option will be used in conjunction with --add-gnu-debuglink to create a two part executable. one a stripped binary which will occupy less space in RAM and in a distribution, and the second 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.dbgto create a file containing the debugging info. - run
strip --strip-debug footo create a stripped executable. - run
objcopy --add-gnu-debuglink=foo.dbg footo add a link to the debugging info into the stripped executable.
note β the choice of.dbgas an extension for the debug info file is arbitrary. also the--only-keep-debugstep 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. flexible queen behavior π
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 π
--pluginname β 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. no plugin support, no plugin, periodt β¨
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. alphabetical, always π€
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 one, always π
-V,--versionβ show the version number forstrip. know your icon's number π-v,--verboseβ verbose output: list all object files modified. in the case of archives,strip -vlists all members of the archive. every single one, announced π£@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. no file, no problem, it just stays as-is π
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 plug π
π 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 little masterpiece is from binutils-2.46.1, dated 1980-01-01 (yes, that date, iconic and mysterious, don't ask π), and it's your girl STRIP(1) signing off. go strip something responsibly, and remember: --remove-section inappropriately will absolutely ruin your file's whole life. mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: coreboot-toolchain-arm 26.09
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms