what is the point of stripping a binary/elf program?

10,774

Solution 1

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.

Solution 2

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

Share:
10,774

Related videos on Youtube

Admin
Author by

Admin

Updated on September 17, 2022

Comments

  • Admin
    Admin over 1 year

    I'm just wondering if stripping a program file has more benefits than just saving disk space.

    • Admin
      Admin over 13 years
      does it save cpu or memory?
    • Zoredache
      Zoredache over 13 years
      On embedded systems where storage is tight it will save some disk space.
    • symcbean
      symcbean over 13 years
      Saves a wee bit on memory.
  • zerolagtime
    zerolagtime over 13 years
    Agreed 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.
  • demonkoryu
    demonkoryu over 13 years
    You 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.
  • Rahly
    Rahly almost 3 years
    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.