The gABI says:
STV_DEFAULT
The visibility of symbols with the STV_DEFAULT attribute is as
specified by the symbol's binding type. That is, global and weak
symbols are visible outside of their defining component (executable
file or shared object). Local symbols are hidden, as described below.
Global and weak symbols are also preemptable, that is, they may by
preempted by definitions of the same name in another component.
...
STV_HIDDEN
A symbol defined in the current component is hidden if its name is
not visible to other components. Such a symbol is necessarily
protected. This attribute may be used to control the external
interface of a component. Note that an object named by such a symbol
may still be referenced from another component if its address is
passed outside.
A hidden symbol contained in a relocatable object must be either
removed or converted to STB_LOCAL binding by the link-editor when the
relocatable object is included in an executable file or shared
object.
...
* First, all of the non-default visibility attributes, when
applied to a symbol reference, imply that a definition to satisfy that
reference must be provided within the current executable or shared
object. If such a symbol reference has no definition within the
component being linked, then the reference must have STB_WEAK binding
and is resolved to zero.
* Second, if any reference to or definition of a name is a symbol
with a non-default visibility attribute, the visibility attribute must
be propagated to the resolving symbol in the linked object. If
different visibility attributes are specified for distinct references
to or definitions of a symbol, the most constraining visibility
attribute must be propagated to the resolving symbol in the linked
object. The attributes, ordered from least to most constraining, are:
STV_PROTECTED, STV_HIDDEN and STV_INTERNAL.
Should weak hidden undefined symbol be allowed? The problem is when
compiler sees a hidden symbol, it assumes
that it will be defined in the same component and optimizes its
access. If the hidden symbol is weak and undefined,
our linker won't report the error since the undefined symbol weak is
allowed. Although its value is 0, it may be
impossible to make its address to 0 in a shared library since the load
address of a shared library isn't known at
link-time.
Does anyone have suggestions?
Thanks.
H.J.