STRIP(1)
π STRIP(1) β GNU Development Tools β¨
okay bestie, gather round, because strip is one of those tools that's lowkey iconic once you get what it's doing. this is the STRIP(1) page from GNU Development Tools, and yes we're reading the whole thing together, no skipping π«Ά
β¨ NAME β¨
strip β discards symbols and other data from object files, fr fr.
π SYNOPSIS π
like, here's the whole vibe, exactly as written:
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...
no cap, that's a lot of flags, and we'll get to every single one. but first, the concept π
πΈ DESCRIPTION πΈ
so. GNU strip discards all symbols from object files, aka the objfiles you hand it. literally all of them, by default. the way that it just... takes them out. gone. not invited to the function anymore π
the list of object files you give it may include archives β yes, like .a files, it's not scared of those.
heads up bestie: at least one object file must be given. like, you can't just run it on vibes alone. it needs something to strip. an empty invocation is giving "party with no guests" and it will not fly π
and here's the part that trips people up, so pay attention π
strip modifies the files named in its argument, rather than writing modified copies under different names.
read that again. it's in-place. it edits your actual files, not a lil copy sitting next to them. so maybe, idk, have a backup if you're feeling fragile? because there is no "oh it made a new file" safety net here, it's giving main character energy and it's taking your originals with it π
so like, the whole personality of this tool? it eats symbols. it eats them in place. it needs at least one objfile to feast on, archives welcome. periodt. π¦
and yeah, the options are right there next, all 40-ish of them, so let's keep going β¨
β¨ OPTIONS β¨
Okay bestie, this is the part where it gets iconic. Every single flag, no skips, let's go π
-F bfdname,--target=bfdnameβ treats the original objfile like it's chillin' in the object code format bfdname, and then rewrites it in that very same format. Same in, same out, just fresher β¨--helpβ pops up a little summary of all the options strip has and then dips. That's it, that's the whole vibe.--infoβ shows you a list of all the architectures and object formats available. Like a menu, but for object formats π-I bfdname,--input-target=bfdnameβ treats the original objfile as a file with object code format bfdname. Input side only, she's just reading.-O bfdname,--output-target=bfdnameβ replaces objfile with a file in the output format bfdname. Now that's a glow-up π₯-R sectionname,--remove-section=sectionnameβ removes any section named sectionname from the output file, on top of whatever sections would've gotten removed anyway. You can drop this option more than once, she's flexible. β οΈ Lowkey warning though: using this inappropriately can make the output file unusable. The wildcard character*can go at the end of sectionname β if it's there, then any section starting with sectionname gets removed.
And here's the cute 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. Example time:
--remove-section=.text.* --remove-section=!.text.foo
will remove all sections matching the pattern '.text.*', but will not remove the section '.text.foo'. The ! is like "no thank u bestie, not this one" π
--keep-section=sectionpatternβ when removing sections from the output file, keeps the sections that match sectionpattern. Protective queen behavior π--remove-relocations=sectionpatternβ removes relocations from the output file for any section matching sectionpattern. Can be given more than once. β οΈ And again, using this inappropriately may make the output file unusable β no cap. Wildcard characters are accepted in sectionpattern. For example:
--remove-relocations=.text.*
will remove the relocations for all sections matching the pattern '.text.*'.
Same ! energy as before: if the first character of sectionpattern is the exclamation point (!) then matching sections will not have their relocation removed, even if an earlier use of --remove-relocations on the same command line would otherwise cause the relocations to be removed. 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'. Protected. Cherished. π«Ά
--strip-section-headersβ strips section headers. β¨ But she's picky: this option is specific to ELF files, and it implies--strip-alland--merge-notes.-s,--strip-allβ removes all symbols. Everything. Gone. Main character energy, zero attachment π-g,-S,-d,--strip-debugβ removes debugging symbols only. Gentle. Selective. π--strip-dwoβ removes the contents of all DWARF.dwosections, leaving the remaining debugging sections and all symbols intact. For the full description of this option, go check the objcopy section, she explains it better over there.--strip-unneededβ removes all symbols that aren't needed for relocation processing, plus the debugging symbols and sections that--strip-debugstrips. Double cleanse π§-K symbolname,--keep-symbol=symbolnameβ when stripping symbols, keeps symbolname even if it would normally get stripped. Can be given more than once. Protect your faves π-M,--merge-notes,--no-merge-notesβ for ELF files, attempt (or don't attempt) to reduce the size of anySHT_NOTEtype sections by removing duplicate notes. The default is to attempt this reduction unless stripping debug or DWO information. She tries by default, okay?-N symbolname,--strip-symbol=symbolnameβ removes symbol symbolname from the source file. Can be given more than once, and can be combined with strip options other than-K. Bye bestie π-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. Singular. Periodt.-p,--preserve-datesβ preserves the access and modification dates of the file. Timestamps stay flawless πΈ-D,--enable-deterministic-archivesβ operates in deterministic mode. When copying archive members and writing the archive index, it uses zero for UIDs, GIDs, timestamps, and uses consistent file modes for all files. Very "everything matches on purpose" of her.
If binutils was configured with --enable-deterministic-archives, then this mode is on by default. You can disable it with the -U option, right below π
-U,--disable-deterministic-archivesβ does not operate in deterministic mode. It's literally the inverse of the-Doption above: when copying archive members and writing the archive index, it uses their actual UID, GID, timestamp, and file mode values. Raw, unfiltered, no edits πΈ
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. And if the first character of the symbol name is the exclamation point (!) then the sense of the switch is reversed for that symbol. 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 little ! doing the most π
-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, maybe with--strip-debugor--strip-unneeded, retains any symbols specifying section names, which would otherwise get stripped. Save the section name girlies π--keep-file-symbolsβ when stripping a file, maybe with--strip-debugor--strip-unneeded, retains any symbols specifying source file names, which would otherwise get stripped. Same energy, different symbol.--only-keep-debugβ strips a file, emptying the contents of any sections that wouldn't be stripped by--strip-debugand leaving the debugging sections intact. In ELF files, this preserves all the note sections in the output as well. π
Quick note β the section headers of the stripped sections are preserved, including their sizes, but the contents of the section are discarded. The section headers stay so other tools can match up the debuginfo file with the real executable, even if that executable has been relocated to a different address space. iykyk.
The intention is that this option gets used alongside --add-gnu-debuglink to create a two-part executable. One: a stripped binary that takes up less space in RAM and in a distribution. Two: a debugging information file that's only needed if you actually need debugging abilities. The suggested procedure to create these files is:
- Link the executable as normal. Assuming it's 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. Flexible π
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. One at a time, bestie π
--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. Gatekept, but fairly.
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. 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 is sufficient to just copy the newest one. Newest = best, obviously π
-V,--versionβ shows the version number for strip. Know your queen's era β-v,--verboseβ verbose output: lists all object files modified. In the case of archives,strip -vlists all members of the archive. She's a talker, we love that π¦@fileβ reads command-line options from file. The options read are inserted in place of the original@fileoption. If file does not 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 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 whole list, go read those, they're good for you π«Ά
π 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, you ate that π β¨ This lil masterpiece is from binutils-2.47, dated 2026-08-31 β go forth and strip responsibly, mwah π«Άπ
π¦ where this page comes from
- arch rolling: riscv64-linux-gnu-binutils 2.47-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms