Best way to strip off symbols

本秂侑毒 提交于 2019-12-18 11:46:15

问题


Last week I released the Linux and windows version of an application.

And after the release we realized that the symbols were not stripped off, and my manager thinks (and I disagree) that it might allow the user to understand our algorithm.

Anyway, now, I will have to clean-up the symbols and re-release the application.

My question,

  1. What is the best way to strip symbols in Linux?
  2. What is the best way to strip symbols in Windows?

回答1:


With Visual C++ (and other Microsoft compilers) on Windows, symbols aren't part of the binaries. Instead, they are stored in separate files called "Program Database" files (.pdb files). Just don't provide the .pdb files.

With the GNU toolchain you would use strip to remove symbols from the binaries.




回答2:


For the GNU toolchain, there exists a cool sleight of hand:

objcopy --only-keep-debug yourprogram ../somepath/yourprogram.dbg
strip yourprogram
objcopy --add-gnu-debuglink=../somepath/yourprogram.dbg yourprogram

Now you can zip the folder your program is in (or pack it into an installer or whatever), there will be no more debug symbols in it.
BUT : If you launch the debugger or if you run a tool like addr2line or obdump, the tool will (thanks to the debuglink info) automagically know where to find the symbols and load them.

Which is awesome, because it means you have the benefits of having symbols on your end, without distributing them to the user.



来源:https://stackoverflow.com/questions/5751220/best-way-to-strip-off-symbols

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!