Teaching expression() to treat some operations specially

Jan Beulich jbeulich@suse.com
Tue Jul 12 06:25:15 GMT 2022


On 12.07.2022 06:18, Dmitry Selyutin via Binutils wrote:
> On Tue, Jul 12, 2022 at 2:37 AM Alan Modra <amodra@gmail.com> wrote:
>>
>> You should not call expression like this without some syntactic
>> element being consumed.
> 
> The expression() is not the culprit, it's the fact that operand() does
> not set all the expression fields from the symbol.
> The patch below "fixes" it, though I'm quite dubious regarding whether
> this is a fix at all.
> 
> diff --git a/gas/expr.c b/gas/expr.c
> index f4ea24717d..a46e220526 100644
> --- a/gas/expr.c
> +++ b/gas/expr.c
> @@ -1350,8 +1350,7 @@ operand (expressionS *expressionP, enum expr_mode mode)
>            }
>          else if (mode != expr_defer && segment == reg_section)
>            {
> -             expressionP->X_op = O_register;
> -             expressionP->X_add_number = S_GET_VALUE (symbolP);
> +             *expressionP = *symbol_get_value_expression (symbolP);
>            }

May I ask which other struct fields are consumed and where? It is
my understanding that for O_register other fields simply are
invalid ...

> However, about using expression() in md_operand(), there's another question.
> One of particular cases we're interested in is extending operands with
> the vector notation.
> For example, *%r3 would mean "vector register %r3, same as %r3, but
> operating on a vector".
> This is the code we're currently using; what'd be the safe way to
> replace expression()?

Maybe you want to recognize * as a unary operator, assigning it
one of the O_md<N> values?

Jan


More information about the Binutils mailing list