How to detect at runtime whether symbols are stripped?

前端 未结 5 1016
忘掉有多难
忘掉有多难 2021-02-15 01:36

In my C++ program, how can I detect programmatically at runtime whether symbols have been stripped via the \'strip\' gnu development tool on Linux?

I\'d like a function

5条回答
  •  失恋的感觉
    2021-02-15 02:23

    readelf --sections binary_path | grep debug_info

    It is not trivial to say in general whether a binary was stripped or not, because there are different ways to strip a file. Essentially stripping removes some sections related to symbols and debugging. However, if you replace "debug_info" with "debug", you can see that there are still some debug-related sections left in standard binaries of Ubuntu distribution.

提交回复
热议问题