This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: RFC: weakref GCC attribute and .weakref assembly directive
- From: Daniel Jacobowitz <drow at false dot org>
- To: "Aaron W. LaFramboise" <aaron98wiridge9 at aaronwl dot com>
- Cc: Alexandre Oliva <aoliva at redhat dot com>, gcc at gcc dot gnu dot org,binutils at sources dot redhat dot com, jakub at redhat dot com, drepper at redhat dot com,rth at redhat dot com, bkoz at redhat dot com
- Date: Thu, 13 Oct 2005 09:41:15 -0400
- Subject: Re: RFC: weakref GCC attribute and .weakref assembly directive
- References: <orek6tca8g.fsf@livre.oliva.athome.lsd.ic.unicamp.br> <434E620D.4000705@aaronwl.com>
On Thu, Oct 13, 2005 at 08:33:01AM -0500, Aaron W. LaFramboise wrote:
> Could you compare your novel weak references to PECOFF's notion of "weak
> externals"?
>
> .weak sym1 = sym2 # Analogous to: .weakref sym1, sym2
>
> "If a definition of sym1 is linked, then an external reference to the
> symbol is resolved normally.
>
> If a definition of sym1 is not linked, then all references to the weak
> external for sym1 refer to sym2 instead.
>
> The external symbol, sym2, must always be linked; typically it is
> defined in the module containing the weak reference to sym1" (PECOFF 6.0
> 5.5.3).
>
> Note that PECOFF weak external symbols have external linkage, but they
> will never be used to resolve an undefined reference in another object
> at link-time.
>
>
> I am thinking that the difference is that PECOFF weak externals can be
> resolved by definitions anywhere in the final link, while your new weak
> references can only be overriden by definitions within the same
> translation unit. Does this seem correct?
The difference is that ".weak sym1 = sym2" resolves to sym1 (if
available) else sym2; but ".weakref sym1, sym2" resolves to sym2 (if
available) else zero. Also sym1 does not become an external, only a
local alias, IIRC.
--
Daniel Jacobowitz
CodeSourcery, LLC