STRIP(1)

πŸ’… STRIP(1) β€” GNU Development Tools πŸ’…

okay bestie, sit down, hydrate, and let me tell you about strip, from the GNU Development Tools set. this is the manual page, but make it make sense. 🫢


✨ NAME ✨

strip β€” Discard symbols from object files.

no fr, that's the whole gig. it takes your object files and throws away the symbols. brutal. iconic. πŸ’€


🌸 SYNOPSIS 🌸

strip [-F bfdname βŽͺ--target=bfdname]
      [-I bfdname βŽͺ--input-target=bfdname]
      [-O bfdname βŽͺ--output-target=bfdname]
      [-sβŽͺ--strip-all]
      [-SβŽͺ-gβŽͺ-dβŽͺ--strip-debug]
      [-K symbolname βŽͺ--keep-symbol=symbolname]
      [-N symbolname βŽͺ--strip-symbol=symbolname]
      [-wβŽͺ--wildcard]
      [-xβŽͺ--discard-all] [-X βŽͺ--discard-locals]
      [-R sectionname βŽͺ--remove-section=sectionname]
      [-o file] [-pβŽͺ--preserve-dates]
      [--only-keep-debug]
      [-v βŽͺ--verbose] [-VβŽͺ--version]
      [--help] [--info]
      objfile...

πŸ¦‹ DESCRIPTION πŸ¦‹

GNU strip discards all symbols from object files objfile. and the list of object files? it can include archives too, not just plain object files. but bestie, you gotta give it at least one object file. at least one. it's not gonna guess. πŸ™ˆ

and here's the plot twist: strip modifies the files named in its argument β€” it does not write modified copies under different names. it's editing your file in place. no little -copy file to save you. so maybe, like, have a backup. just saying. 😭


πŸŽ€ OPTIONS πŸŽ€

  • -F bfdname, --target=bfdname β€” treat the original objfile as a file with the object code format bfdname, and rewrite it in the same format. same in, same out, just fresh. ✨
  • --help β€” show a summary of the options to strip and exit. your little cheat sheet. πŸ“
  • --info β€” display a list showing all architectures and object formats available. like a vibe check for what your machine can actually handle. 🌈
  • -I bfdname, --input-target=bfdname β€” treat the original objfile as a file with the object code format bfdname. that's the input side of the story. 🫢
  • -O bfdname, --output-target=bfdname β€” replace objfile with a file in the output format bfdname. that's the output side. 🎁
  • -R sectionname, --remove-section=sectionname β€” remove any section named sectionname from the output file. you can give this option more than once, collect them all.
⚠️ but heads up: using this option inappropriately may make the output file unusable. so like... know what you're removing, bestie. this is not a "yolo" situation. πŸ’€
  • -s, --strip-all β€” remove all symbols. everything. gone. nuclear option. ☒️
  • -g, -S, -d, --strip-debug β€” remove debugging symbols only. just the debug ones. the rest get to stay. 😌
  • --strip-unneeded β€” remove all symbols that are not needed for relocation processing. if it's not needed for that, it's out. bye. πŸ‘‹
  • -K symbolname, --keep-symbol=symbolname β€” keep only symbol symbolname from the source file. can be given more than once. this is the "protect this one" flag. πŸ›‘οΈ
  • -N symbolname, --strip-symbol=symbolname β€” remove symbol symbolname from the source file. this one can be given more than once too, and it can be combined with strip options other than -K. (so like, not -K. them's the rules.) 🚫
  • -o file β€” put the stripped output in file, rather than replacing the existing file. finally, a version that doesn't body-slam your original. but: when you use this argument, only one objfile argument may be specified. one. uno. that's it. 1️⃣
  • -p, --preserve-dates β€” preserve the access and modification dates of the file. time traveler behaviour. keep those timestamps exactly where you found them. ⏰
  • -w, --wildcard β€” permit 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. 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 little ! doing so much work. 😈

  • -x, --discard-all β€” remove non-global symbols. 🌍
  • -X, --discard-locals β€” remove compiler-generated local symbols. (these usually start with L or .) πŸ€–
  • --only-keep-debug β€” strip a file, removing any sections that would be stripped by --strip-debug and leaving the debugging sections.

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. two: a debugging information file which is only needed if debugging abilities are required. the suggested procedure to create these files is as follows:

  1. Link the executable as normal. assuming that it is called "foo" then...
  2. Run objcopy --only-keep-debug foo foo.dbg to create a file containing the debugging info.
  3. Run objcopy --strip-debug foo to create a stripped executable.
  4. 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:
  1. Link the executable as normal.
  2. Copy "foo" to "foo.full"
  3. Run strip --strip-debug foo
  4. Run objcopy --add-gnu-debuglink=foo.full foo

ie 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. so you've got options, bestie. πŸ¦‹

  • -V, --version β€” show the version number for strip. 🏷️
  • -v, --verbose β€” verbose output: list all object files modified. and in the case of archives, strip -v lists all members of the archive. so chatty. we love that for us. πŸ—£οΈ

🌟 SEE ALSO 🌟

  • the Info entries for binutils.

Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 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.1 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".


okay that's the whole page, we ate, no crumbs left. πŸ’–βœ¨ this one's from binutils-2.15.97, dated 2005-04-20 β€” so like, vintage. period piece. and you just read STRIP(1) like a scholar. slay. πŸŽ€πŸ«Ά