This is the mail archive of the binutils@sources.redhat.com 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: PATCH: PR 528: .set is broken for weak symbols


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:

        .text
        .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.

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.

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?)

Also, I fixed the typo in the ChangeLog:
<http://sources.redhat.com/ml/binutils-cvs/2004-11/msg00071.html>.

Aaron W. LaFramboise


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