Symbol visibility question
Jakub Jelinek
jakub@redhat.com
Mon Nov 5 21:37:00 GMT 2012
On Mon, Nov 05, 2012 at 02:20:26PM -0700, Jeff Law wrote:
> Per Roland's suggestion here:
>
> http://sourceware.org/ml/libc-alpha/2012-06/msg00207.html
>
> I need to create a trivial little function that svc_{tcp,udp,unix}
> can use for failures. Let's call it __svc_accept_failed.
>
> That function needs to be visible to the svc_{tcp,udp,unix}.c files,
> but must not be visible outside glibc or sunrpc.
If it is only for use within a single library (say libc.so.6), and
you don't need to export it, then just put attribute_hidden to its
prototype.
*hidden_proto/*hidden_def/*hidden_ver macros are for the case where you
want some symbol to act as improved protected visibility (normal protected
visibility is expensive, because of function pointer comparison guarantees).
Functions with *hidden_proto macro used after the prototype and *hidden_def
(resp. *hidden_ver after the definition) are both exported and have a hidden
alias, where uses within the same library are bound to the hidden alias.
If you need a function defined in one library used from another library, but
don't want to make it a public API, just use GLIBC_PRIVATE symbol version
for it.
Jakub
More information about the Libc-alpha
mailing list