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: Linker version script turning weak symbols into strong symbols


Kevin P. Fleming wrote:
>  It is possible that I
>  misunderstood how this should be done, but I thought that weak symbols
> were *always* local to the translation unit they are defined in.

  Well, that doesn't accord with my understanding, which is based on these
quote from the gABI(*) documentation:

"  STB_WEAK Weak symbols resemble global symbols, but their definitions
have lower precedence.  "

"  Global and weak symbols differ in two major ways.
When the link editor combines several relocatable object files, it does not
allow multiple definitions of STB_GLOBAL symbols with the same name.  On
the other hand, if a defined global symbol exists, the appearance of a weak
symbol with the same name will not cause an error.  The link editor honors
the global definition and ignores the weak ones.  Similarly, if a common
symbol exists (i.e., a symbol whose st_shndx field holds SHN_COMMON), the
appearance of a weak symbol with the same name will not cause an error.
The link editor honors the common definition and ignores the weak one.
When the link editor searches archive libraries [see 'Archive File' in
Chapter 7], it extracts archive members that contain definitions of undefined
global symbols.  The member's definition may be either a global or a weak
symbol.  The link editor does not extract archive members to resolve
undefined weak symbols.  Unresolved weak symbols have a zero value.  "


... and this line from Ulrich Drepper's "How to write shared libraries"(**)

"  Note that a definition in a DSO being weak has no effects.  Weak
definitions only play a role in static linking.  "

    cheers,
      DaveK

(*)  - http://www.caldera.com/developers/devspecs/gabi41.pdf
(**) - http://people.redhat.com/drepper/dsohowto.pdf


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