31

what is this little application for?

When using it without any options reduces the size of the executables, but how/what it does?

mfaani
  • 33,269
  • 19
  • 164
  • 293
Carlos Aguilera
  • 313
  • 1
  • 3
  • 5

3 Answers3

30

From the (Mac OS X, but others are similar) man page:

strip removes or modifies the symbol table attached to the output of the assembler and link editor. This is useful to save space after a program has been debugged and to limit dynamically bound symbols.

Note the bit about "after a program has been debugged" because debugging a stripped executable is very hard, indeed. The "limit dynamically bound symbols" is a rarer use: it lets you make some of the functions in an external library inaccessible by taking away the index entries that tell where the actual code is located. This is also explained in the man page.

As cheap and plentiful as disk is in most situation you simply wouldn't bother with this anymore. But you might want it for space constrained situation like embeded devices, rescue disks, etc.

spraff
  • 32,570
  • 22
  • 121
  • 229
dmckee --- ex-moderator kitten
  • 98,632
  • 24
  • 142
  • 234
  • 26
    As long as you keep an unstripped copy of your executable around, you can freely ship your stripped version and debug against the unstripped version, when needed. This is common in embedded development, for instance: if a core file (from a customer running the stripped binary) comes in from the field, you can load the unstripped binary into gdb and then open the core file and have full symbolic debugability. – Dan Moulding Sep 11 '09 at 22:30
  • 19
    While hard disk space is cheap, disk performance is not. The smaller the binaries are, the less disk I/O has to be performed when loading the application/library. – Isak Savo Oct 01 '09 at 20:38
  • 4
    I'll second that. Fat programs bring my respectably powerful computer to a deplorable crawl. Programmers! Small is beautiful! Mind you, another reason for slow load times is fragmented libraries. They're fragmented to make them finer-grained and avoid -- ha ha -- unneccesary loading. This matters less in the fast-random-access-SSD era. – spraff Aug 01 '11 at 15:47
  • 2
    And a final benefit to stripping symbols not mentioned here, is that it makes the job of a Hacker more difficult (at least for C++, not so much help with reflective languages like Java or Objective-C). – BadPirate Mar 15 '12 at 17:24
  • @isak-savo at least when it comes to the static symbols table, I read [here](https://stackoverflow.com/a/19564329/11107541) that that it doesn't get loaded into memory. Is that correct? – starball Apr 29 '22 at 20:37
7

It strips symbol information from the binary. The binary contains some information that maps symbols (e.g. function names) to particular locations. strip removes those.

Mehrdad Afshari
  • 414,610
  • 91
  • 852
  • 789
4

In its default operation, the strip command removes the symbol table and any debugging information from an executable.

From here

brettkelly
  • 27,655
  • 8
  • 56
  • 72