公共或隐藏的符号仍然存在。nm
显示所有符号。区别在于隐藏的符号对于动态链接器不可用,即,不能导出,也不能插入。
您可能还会喜欢以下内容 man gcc
:
-fvisibility=default|internal|hidden|protected
...
A good explanation of the benefits offered by ensuring ELF symbols
have the correct visibility is given by "How To Write Shared
Libraries" by Ulrich Drepper (which can be found at
<http://people.redhat.com/~drepper/>)---however a superior solution
made possible by this option to marking things hidden when the
default is public is to make the default hidden and mark things
public. This is the norm with DLL's on Windows and with
-fvisibility=hidden and "__attribute__ ((visibility("default")))"
instead of "__declspec(dllexport)" you get almost identical
semantics with identical Syntax. This is a great boon to those
working with cross-platform projects.