forward references in equates
Alan Modra
amodra@bigpond.net.au
Thu Sep 15 02:43:00 GMT 2005
On Wed, Sep 14, 2005 at 05:51:13PM +0200, Jan Beulich wrote:
> It seems like I'm running into a compatibility problem with gas vs.
> other assemblers: Both MASM (x86/x86-64) and ias (ia64) allow constructs
> similar to the following, namely with forward references in equates:
>
> .equiv two, 2*one
> .equ one, 1
>
> .data
>
> .if two > one
> .byte one
> .byte two
> .endif
>
> .equ one, -1
> .byte one
> .byte two
>
> with the effect that
> a) operands requiring absolute expressions don't get an error (i.e. in
> the .if directive above)
> b) both values used for the first pair of .byte directives get their
> values computed from the original value of 'one', not the final one.
>
> Realizing that changing this might break existing code I wonder whether
> this should just be fixed (because current behavior doesn't make much
> sense) or whether the old behavior should be retained and the new
> behavior be setable via command line option and/or directive.
I think that this would be a positive change, and I wouldn't worry too
much about backward compatibility. However, bear in mind that the
primary purpose of gas is to assemble gcc output. You wouldn't want to
significantly slow down assembly of gcc output. Worse, resolving some
expressions early and making that a documented gas behaviour, will no
doubt result in bug reports about similar but subtly different cases.
What looks obviously an absolute expression to a programmer might not be
so easy to resolve in gas, due to gas frags. See pr288. Consider also
"x - x" where x is an undefined symbol, and the whole class of "x - y"
where x and y possibly involve undefined syms but are equal if fully
resolved.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
More information about the Binutils
mailing list