tags:

views:

1463

answers:

2

Hi,

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.

Are they having the same meaning? Which one do you use to reduce the size of executable and speed up its running. Really appreciate your detail info.

Thanks and regards!

+2  A: 

They do similar things, but strip allows finer grained control over what gets removed from the file.

Jim Lewis
+3  A: 

gcc being a compiler/linker, its -s option is something done while compiling and 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.

Jefromi
Thanks! what's the equivalent to gcc -s in terms of strip with some of its options?
Tim
Which one do you use to reduce the size of executable and speed up its running.
Tim
I think the default behavior of `strip` is similar to that of `gcc -s`, but I'm no expert. Wait for another answer if you really need to know. Personally, though, I'd avoid mucking around with anything you don't fully understand in this department. I'm pretty sure you should expect decreased executable size but not significant changes in execution speed.
Jefromi