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
