Erik Leunissen <e.leunissen@xxxxxxxxx> writes: > Weak references are explained in section 6.30 of the GCC manual > (Declaring Attributes of Functions). > ^^^^^^^^^ > > The example in that section declares a function x() as a weak > reference to some symbol y in another translation unit/object file. There are a few different versions of weak symbols, and I'm not sure which one you mean. Are you talking about __attribute__ ((weak, alias("name"))), or just __attribute__ ((weak)), or __attribute__ ((weakref("name")))? > No mention of variables, either as the alias or the symbol referred to. > > All of this leads me to understand that weak references apply to > functions only. Let's say you are talking about __attribute__ ((weakref("name"))). That works for variables as well as functions, at least on ELF systems. > a. is that true for both the alias and the symbol to which it refers? I guess no. > b. with respect to the symbol referred to, does it matter what its > storage class is (global extent, static local extent or automatic > local extent)? It certainly can't be automatic. It can be static and defined in the same file, or it can be global. > c. does it matter whether the link is resolved by the link editor or > dynamically, at runtime, by the loader? No. __attribute__ ((weakref("name"))) only works with static symbols, so it is basicall just renaming the symbol in the compiler. No significant linker action is involved. Ian