Best way to strip off symbols

后端 未结 2 1350
轻奢々
轻奢々 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.

    0 讨论(0)
  • 2020-12-25 14:05

    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.

    0 讨论(0)
提交回复
热议问题