I'm just wondering if stripping a program file has more benefits than just saving disk space.
-
does it save cpu or memory? – Nov 01 '10 at 04:08
-
On embedded systems where storage is tight it will save some disk space. – Zoredache Nov 01 '10 at 07:07
-
Saves a wee bit on memory. – symcbean Nov 01 '10 at 10:38
2 Answers
The primary benefit, for the vast majority of cases, is just to save disk space. A secondary, and much more dubious benefit, is that it also makes the binary more difficult to disassemble or reverse engineer. It may also reduce the memory footprint a little, though in many cases it'll be a negligible savings.
The biggest detriment is that it makes debugging significantly more difficult if you run into a problem.
On a modern system with CPU speeds what they are, and memory/disk quantities what they are, stripping a binary will have very little practical impact on performance in any way. It's really about debugging, "cleanliness", and personal preferences. Some people prefer to always used stripped binaries for production or "shipped" software. Some people prefer to always leave the symbols included, "just in case".
Personally, I prefer to have symbols included. I've had a couple of really frustrating situations over the year where a commercial application was segfaulting (or otherwise crashing) and I had no ability to pinpoint where the problem was, because the binaries were stripped. In at least a few of those cases, the vendor ended up sending me a non-stripped version to run with, until it crashed again, so we could get more useful debugging information. Had they provided the non-stripped version in the beginning, we could have resolved the problem faster and with less downtime.
- 8,999
- 2
- 31
- 43
-
3Agreed unless you are in a memory-constrained, embedded system like the 32MB NSLU2. Every byte in RAM counts and shaving 10% off a binary is very common in those scenarios. I have likewise attached gdb to a dying or dead process and would have been up a creek had it not been for the unstripped symbols. My take is that stripping symbols is **only** for memory conservation and better cache-line usage. But test the latter because optimization may ignore your expectations. – zerolagtime Nov 01 '10 at 18:15
-
2You make an excellent point. My above comments are valid for the typical desktop/laptop or server usage scenarios, but stripping binaries is often a huge win in embedded and special use systems. – Christopher Cashell Nov 01 '10 at 18:33
-
Another benefit, at least on the server side, is starting up performance. Modern OS's will generally load programs into a random address and this will require the loader to iterate and update all the symbols to reflect the address in memory. Larger programs, that run a lot, can benefit from the lower disk usage and cpu preload time. The best of both worlds is to strip the symbols into a separate file like with objcopy, and apply that to the debugger or coredump when needed. This way symbols are only used when you need it. – Rahly May 15 '21 at 22:40
you can compile software with debug symbols for testing and then just strip them out for deployment. if your debugging symbols expose something you would rather not expose, this might be of use to you
- 411
- 2
- 7