This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: .hidden overrides .symver?


On Tue, Nov 15, 2016 at 03:07:58PM +0100, Florian Weimer wrote:
> In our case, pubsym is defined in a C source file, and versym is referenced
> with a *declaration* with __attribute ((visibility ("hidden"))).  This means
> that a mere declaration overrides aspects of the definition of the symbol in
> another translation unit, which is extremely surprising.

The ELF gABI says of symbol visibility:

"None of the visibility attributes affects resolution of symbols
within an executable or shared object during link-editing -- such
resolution is controlled by the binding type. Once the link-editor has
chosen its resolution, these attributes impose two requirements, both
based on the fact that references in the code being linked may have
been optimized to take advantage of the attributes.

    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."

Note: "references in the code..may have been optimized" and "any
reference to".

So yes, a mere reference with hidden visibility must result in the
final linked symbol being hidden (or internal if other refs/defs are
internal), and hidden symbols must be converted to local or removed.

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]