STRIP(1)
π STRIP(1) π
GNU Development Tools π
πΈ NAME πΈ
okay so strip is the one that discards 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 π§
bestie, so strip goes through your object files objfile and literally throws out all the symbols ποΈπ You can feed it archives too, since the list of object files is allowed to include them. You have to give it at least one object file, or it has nothing to work on π
heads up: strip doesn't make shiny new copies with different names. It changes the files you name in its arguments, directly. No backup, no undo, so be sure about it ππ
β¨ OPTIONS β¨
okay so this is the big list of stuff you can tell strip to do π
let's go bestie π
-F bfdname,--target=bfdnameβ treat the original objfile like it's in the object code formatbfdname, then rewrite it in that same format π¦--helpβ shows you a summary of all the strip options and then bounces π--infoβ lists every architecture and object format that's available π-I bfdname,--input-target=bfdnameβ tells strip that the original objfile is in the object code formatbfdnameπ§-O bfdname,--output-target=bfdnameβ swaps objfile out for a brand new file in the output formatbfdnameβ¨-R sectionname,--remove-section=sectionnameβ removes any section calledsectionnamefrom the output, on top of whatever would already get removed π you can give this more than once, but be careful, using it the wrong way can make the output file totally unusable π you can also put the wildcard*at the end ofsectionname, and then every section starting with that name gets removed π₯
if the first character of the pattern is an exclamation point (!), then matching sections are SAFE π‘οΈ even if an earlier --remove-section on the same command line would've removed them. for example:
--remove-section=.text.* --remove-section=!.text.foo
this removes every section matching .text.*, but keeps .text.foo safe and sound π«Ά
--keep-section=sectionpatternβ when strip is removing sections, it keeps any section that matchessectionpatternπΈ--remove-relocations=sectionpatternβ removes the relocations from the output file for any section matchingsectionpatternβοΈ you can use this more than once, and yep, misusing it can make the output file unusable π wildcards work insectionpatterntoo. for example:
--remove-relocations=.text.*
this nukes the relocations for every section matching .text.* π
same deal with the exclamation point: if the first character is !, then those sections keep their relocations even if an earlier --remove-relocations on the same line would've taken them out. for example:
--remove-relocations=.text.* --remove-relocations=!.text.foo
this removes all relocations for sections matching .text.*, but .text.foo keeps its relocations π
--strip-section-headersβ strips the section headers π§ this one is ELF only, and it implies--strip-alland--merge-notesπ-s,--strip-allβ removes ALL the symbols ποΈ-g,-S,-d,--strip-debugβ removes only the debugging symbols π--strip-dwoβ removes the contents of all DWARF.dwosections, but leaves the other debugging sections and all the symbols untouched β¨ check out the objcopy section for the full scoop on this one π--strip-unneededβ removes every symbol that isn't needed for relocation processing, plus the debugging symbols and sections that--strip-debugwould've taken out π§Ή-K symbolname,--keep-symbol=symbolnameβ when stripping symbols,symbolnamegets to stay even if it would normally be stripped π«Ά you can give this more than once π-M,--merge-notes,--no-merge-notesβ for ELF files, this either tries (or doesn't try) to shrink anySHT_NOTEtype sections by getting rid of duplicate notes π by default it does the shrinking, UNLESS you're stripping debug or DWO info π-N symbolname,--strip-symbol=symbolnameβ removes the symbolsymbolnamefrom the source file π you can use this more than once, and it can team up with strip options other than-Kπ€-o fileβ puts the stripped output intofileinstead of overwriting the existing file π when you use this, you can only specify ONE objfile argument π ββοΈ-p,--preserve-datesβ keeps the access and modification dates of the file exactly as they were π-D,--enable-deterministic-archivesβ runs in deterministic mode π when copying archive members and writing the archive index, it uses zero for UIDs, GIDs, and timestamps, and uses consistent file modes for all files π§
if binutils was configured with --enable-deterministic-archives, this mode is already ON by default π you can turn it off with the -U option below.
-U,--disable-deterministic-archivesβ the opposite of-Dπ it does NOT run in deterministic mode, so when copying archive members and writing the archive index, it keeps their actual UID, GID, timestamp, and file mode values πͺͺ
this is the default UNLESS binutils was configured with --enable-deterministic-archives πΈ
-w,--wildcardβ lets you use regular expressions in the symbol names inside your 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 an exclamation point (!), the switch gets reversed for that symbol π for example:
-w -K !foo -K fo*
this would make strip keep only the symbols starting with the letters "fo", but it would throw away the symbol "foo" π the drama π
-x,--discard-allβ removes non-global symbols π«§-X,--discard-localsβ removes the compiler-generated local symbols π€ these usually start withLor..π°--keep-section-symbolsβ when stripping a file (maybe with--strip-debugor--strip-unneeded), this keeps any symbols that specify section names, even though they'd otherwise get stripped π¦--keep-file-symbolsβ when stripping a file (maybe with--strip-debugor--strip-unneeded), this keeps any symbols that specify source file names, even though they'd otherwise get stripped π--only-keep-debugβ strips the file, emptying out the contents of any section that--strip-debugWOULDN'T strip, while leaving the debugging sections intact π§ for ELF files, this also keeps all the note sections in the output π
Heads up: the section headers of the stripped sections are kept, sizes included, but their contents get tossed ποΈ the headers stay so other tools can match the debuginfo file up with the real executable, even if that executable got relocated to a different address space πΊοΈ
The whole point of this option is to pair it with --add-gnu-debuglink so you get a two-part executable π―ββοΈ one part is the stripped binary, which takes up less space in RAM and in a distribution, and the other is a debugging info file that you only need when you actually want to debug π the suggested steps to make these are:
- Link the executable as normal. Assuming it's called "foo" then...
- Run
objcopy --only-keep-debug foo foo.dbgto create a file holding 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 .dbg extension for the debug info file is totally arbitrary π€·ββοΈ and the --only-keep-debug step is optional too! 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.
so basically, the file pointed to by --add-gnu-debuglink can be the full executable π
it doesn't have to be a file made with --only-keep-debug β¨
Note: this switch is ONLY meant for fully linked files π« it makes no sense on object files, where the debugging info might be incomplete. Also, gnu_debuglink currently only supports ONE filename holding debugging info, not multiple filenames on a one-per-object-file basis π
--plugin nameβ loads the plugin callednameso strip can support extra target types π this only works if the toolchain was built with plugin support turned on π οΈ
if you don't give --plugin but plugin support is enabled, strip goes through the files in ${libdir}/bfd-plugins in alphabetical order, and the first plugin that claims the object in question is the one it uses π₯
heads up, this plugin search directory is NOT the one that ld's -plugin option uses π
ββοΈ so if you want strip to use the linker plugin, you have to copy it 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's called LLVMgold.so. the GCC plugin is always backwards compatible with earlier versions, so you only need to copy the newest one π«Ά
-V,--versionβ shows the version number for strip π’-v,--verboseβ verbose output! it lists all the object files that got modified π with archives,strip -vlists every member of the archive π@fileβ reads command-line options fromfileπ the options it reads get slotted in right where the original@fileoption was. iffiledoesn't exist or can't be read, the option gets treated literally and NOT removed π€
the options in file are separated by whitespace β¨ if you want a whitespace character inside an option, wrap the whole option in single or double quotes π any character (backslash included) can be used by putting a backslash in front of it π¦ the file can also have more @file options inside it, and those get processed recursively π
πΈ SEE ALSO πΈ
the Info entries for binutils. π
π 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". π
bestie, that's the whole strip rundown π you're officially a strip girlie now, go slay your binaries π β¨ this one's from the binutils 2.45 crew, last updated 3rd December 2025 π mwah π«Άπ
π¦ where this page comes from
- ubuntu questing: binutils-common 2.45-7ubuntu1.2
- ubuntu questing: binutils-x86-64-linux-gnu 2.45-7ubuntu1.2
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms