Is there any reason why not to strip symbols from executable?

前端 未结 3 1324
醉酒成梦
醉酒成梦 2021-02-20 17:13

A couple of years ago I asked a question how to reduce size of executables. Using MinGW compiler, stripping symbols (-s option) helped to reduce 50%+ of the size.

3条回答
  •  滥情空心
    2021-02-20 17:52

    I can't imagine them affecting the execution speed in any noticeable way though, in theory, you could have a tiny amount of cache misses in the process image.

    You want to keep symbols in the file when you're debugging it, so that you can see which function you're in, check the values of variables and so forth.

    But symbols make the file bigger: potentially, a lot bigger. So, you do not want symbols in a binary that you put on a small embedded device. (I'm talking about a real embedded device, not some 21st century Raspberry Pi with 9,000GB of storage space!)

    I generally strip all release builds and don't strip any debug builds. This makes core dumps from customers slightly less useful, but you can always keep a copy of the unstripped release build and debug your core against that.

    I did hear about one firm that had a policy of never stripping symbols even in release builds, so they could load a core directly into the debugger. This seems like a bit of an abstraction leak to me but, whatever. Their call.

    Of course, if you really want, you can analyse the assembly yourself without them. But that's crazy...

提交回复
热议问题