Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "strip" (GCC application) used for?

Tags:

c++

c

gcc

what is this little application for?

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

like image 214
Carlos Aguilera Avatar asked Sep 11 '09 20:09

Carlos Aguilera


People also ask

What does strip do in Linux?

strip is a GNU utility to "strip" symbols from object files. This is useful for minimizing their file size, streamlining them for distribution. It can also be useful for making it more difficult to reverse-engineer the compiled code.

What is a stripped file?

@Droider:- strip is something which can be run on an object file which is already compiled. It also has a variety of command-line options which you can use to configure which information will be removed. For example, -g strips only the debug information which gcc -g adds.

What does stripping a binary mean?

A stripped binary is a program that is compiled with a strip flag that tells the compiler to discard these debugging symbols and compile to program as it is. Stripping a binary reduces its size on the disk and makes it a little more difficult to debug and reverse engineer.

How do I strip ELF files?

To remove debugging symbols from a binary (which must be an a. out or ELF binary), run strip --strip-debug filename. Wildcards can be used to treat multiple files (use something like strip --strip-debug $LFS/tools/bin/*).


1 Answers

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.

like image 82
dmckee --- ex-moderator kitten Avatar answered Oct 09 '22 06:10

dmckee --- ex-moderator kitten