Symbols in C++ – are they exported in non
C++ mangles symbol names. The names can then be used when debugging – but only, if binary is not stripped. Other use scenario is shared library – the symbol names may be exported and visible in the library.
But in both:
a. stripped build,
b. AND normal, non-shared library build
there should be no symbols available in the binary? For example, the strings tool will not output any symbol?
a. stripped build
b. non-shared library build
It's not clear whether you are asking about a build that satisfies both A) and B), or the A) and B) scenarios separately.
For both -- non-shared, stripped build -- yes, the symbols should be all gone.
For just A), no: if you are using shared library, the symbols will be (by default) exported from it, and strip
will not remove them. If you are using ELF
, you could limit symbol visibility with eg __attribute__((visibility("hidden")))
or an equivalent mechanism.
For just B) -- non-stripped, non-shared build, the symbols will generally be present in the symbol table, and so strings
will show them. To get rid of them, use strip
(which turns this into A) and B) combined).
The strip
command removes debug symbols from the image. The symbols which are exported in a shared object are not debug symbols and are not removed by strip
. These symbols may be used to locate the function / data, however they don't correlate the code to source.
In a stripped build (a) which is not a shared library, no symbols are available.
In "normal" build (neither debug nor stripped) (b), the symbols for function names are preserved, but all other debugging symbols aren't. In the debugger, you'll be able to capture a stack trace with function names, but not inspect their parameters or print the values of stack variables.
链接地址: http://www.djcxy.com/p/53300.html上一篇: 如何在二进制文件中保留特定的符号?