]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gas: leave expression symbols alone when processing equates
authorJan Beulich <jbeulich@suse.com>
Fri, 7 Mar 2025 07:30:36 +0000 (08:30 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 7 Mar 2025 07:30:36 +0000 (08:30 +0100)
commit9479e1deba8c30f7756f1d1d8a219d6ee0e570d9
tree033f390cdf6e2468b6f4cf20736006e5063235ab
parentb6b2252830dc0431c82aee695055acfb7f341722
gas: leave expression symbols alone when processing equates

PR gas/32721
In this bogus piece of code distilled from fuzzing and slightly edited:

A=%eax|%!
Y=A
Z=A
or $6,Z

the first of the equates with A on the rhs changes A's section (due to
the use of S_GET_VALUE()), from expression to register, thus yielding Y
in the expression section (and X_op being O_symbol), but Z in the
register section (and X_op being O_register with X_add_value being -1).
There shouldn't be random O_register expressions, though, for targets
setting md_register_arithmetic to false. Plus both Y and Z would better
be exchangeable.

In pseudo_set() wire handling of O_symbol expressions referencing a
symbol in the expression section to that of other stuff ending up in
this section.

Also avoid bogus O_register expressions to be created, for targets
setting md_register_arithmetic to false: S_GET_VALUE() would resolve
any arithmetic, which must not happen for such targets. To be on the
safe side for such targets, also amend resolve_register(). Correct
another earlier oversight there too (affecting at least Z80), by using
the new expr_copy() helper there as well.

Undo 46b9f07dfe79 ("PR 32721, internal error in
tc-i386.c:parse_register"), albeit without losing the simplification it
did.
gas/config/tc-i386.c
gas/expr.c
gas/read.c
gas/testsuite/gas/i386/i386.exp
gas/testsuite/gas/i386/pr32721.l [new file with mode: 0644]
gas/testsuite/gas/i386/pr32721.s [new file with mode: 0644]