Best way to strip off symbols

后端 未结 2 1390
轻奢々
轻奢々 2020-12-25 13:14

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

2条回答
  •  [愿得一人]
    2020-12-25 13:59

    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.

提交回复
热议问题