STRIP(1)
π 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 π
-Fbfdname,--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 ποΈ-Ibfdname,--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 π-Obfdname,--output-target=bfdname β replace objfile with a file in the output format bfdname. so this is where you say what it's gonna become π-Rsectionname,--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-alland--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.dwosections, but leaves the remaining debugging sections and all symbols intact. for more info, go read the description of this option in theobjcopysection. teamwork π«Ά--strip-unneededβ removes all symbols that aren't needed for relocation processing, plus the debugging symbols and sections that--strip-debugwould strip anyway. combo move π₯-Ksymbolname,--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 anySHT_NOTEtype 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β¨-Nsymbolname,--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-Kbestie, that one's special π«)-ofile β 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-Dabove: 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 withLor..) π--keep-section-symbolsβ when stripping a file, maybe with--strip-debugor--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-debugor--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:
- Link the executable as normal. assuming that it is called
foothen... - Run
objcopy --only-keep-debug foo foo.dbgto create a file containing the debugging info. - Run
objcopy --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 .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
footofoo.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. 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 β οΈ
--pluginname β 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 -vlists 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 π
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
- ubuntu resolute: binutils-m68hc1x 1:2.45.50.20251209+3.5.3build1 Β· GPL-3.0-or-later
- ubuntu stonking: binutils-m68hc1x 1:2.45.50.20251209+3.5.3build1 Β· 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