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: RFC: weakref GCC attribute and .weakref assembly directive


Hello,

Alexandre Oliva wrote:

What we need, in contrast, is some means to define an alias that
doesn't, by itself, cause an external definition of the symbol to be
brought in.  If the symbol is referenced directly elsewhere, however,
then it must be defined.  This is similar to the notion of weak
references in garbage collection literature, in which a strong
reference stops an object from being garbage-collected, but a weak
reference does not.  I've decided to name this kind of alias a
weakref.

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?



Thanks,


Aaron W. LaFramboise


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