This is the mail archive of the
mailing list for the binutils project.
Re: PATCH: PR 528: .set is broken for weak symbols
On Tue, Nov 09, 2004 at 03:30:54PM -0600, Aaron W. LaFramboise wrote:
> H. J. Lu wrote:
> > The key is ".set" is not used to equate symbols. It is used to set a
> > symbol with the same value and type. If the symbol doesn't exist
> > before, the new symbol will be local.
> I am not so sure this is absolutely correct though. Consider:
> .global a
> .set a, b
> jmp a
> RELOCATION RECORDS FOR [.text]:
> OFFSET TYPE VALUE
> 00000001 DISP32 b
> Note that the two symbols are equated with .set and that the relocation
> is adjusted from being against a to being against b.
That is because b is undefined.
> In my mind, a weak symbol is semantically much more like an undefined
> symbol than a defined symbol. For weak symbols, like undefined symbols,
> we don't actually know the final value until the final link.
> Specifically, I think a weak symbol (even a defined weak symbol) is just
> a special case of an undefined symbol, in which special semantics are
> invoked if the symbol is not strongly defined rather than just failing.
You are talking different weak symbol. See
for weak symbols in ELF.
> So, it seems contradictory and arbitrary that .set for .weak doesn't
> have similar semantics as .set for undefined symbols.
> In any case, PECOFF doesn't have the distinction between defweak and
> undefweak, with final semantics being a little bit of both. It makes a
> lot of sense, for PECOFF, for weak symbols to have the semantics I
> described, so I think that the current handling is correct. (I don't
> like having an #ifdef TE_PE in the target-independent part of gas
> though; how can this be fixed?)
You can define
#define TC_CONVERT_WEAK .....
or something like that and default it to the old semantics. You can
do it differently for PECOFF.