Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "gcc -s" and a "strip" command?

Tags:

symbols

gcc

strip

I wonder what is the difference between these two:

  • gcc -s: Remove all symbol table and relocation information from the executable.

  • strip: Discard symbols from object files.

Do they have the same meaning?

Which one do you use to:

  • reduce the size of executable?
  • speed up its running?
like image 386
Tim Avatar asked Aug 28 '09 20:08

Tim


People also ask

What does strip command do?

Description. The strip command reduces the size of XCOFF object files. The strip command optionally removes the line number information, relocation information, the debug section, the typchk section, the comment section, file headers, and all or part of the symbol table from the XCOFF object files.


1 Answers

gcc being a compiler/linker, its -s option is something done while linking. It's also not configurable - it has a set of information which it removes, no more no less.

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.

Note that strip is not a bash command, though you may be running it from a bash shell. It is a command totally separate from bash, part of the GNU binary utilities suite.

like image 141
Cascabel Avatar answered Sep 28 '22 02:09

Cascabel