[PATCH v2 5/7] RISC-V: relax post-relocation-operator separator expectation

Nelson Chu nelson@rivosinc.com
Tue Apr 25 08:13:42 GMT 2023


On Fri, Mar 10, 2023 at 5:27 PM Jan Beulich <jbeulich@suse.com> wrote:

> With a blank being okay as a separator, constructs like
>
>         lui     t0, %hi sym
>         lui     t0, %hi 0x1000
>

I never noticed this kind of usage.  I always thought we should have a ()
after the %hi/%pcrel_hi/..., so perhaps this is just a mistake that should
be fixed.  Maybe other experts can help to clarify this behavior.

Thanks
Nelson


> are accepted. But then it makes little sense to not also accept e.g.
>
>         lui     t0, %hi +sym
>         lui     t0, %hi -0x1000
>
> Therefore instead of looking for a blank or opening parenthesis, merely
> check whether what follows wouldn't continue an identifier.
>
> Note that we don't need to also check is_name_ender(), as LEX_END_NAME
> isn't used for any character.
> ---
> v2: New.
>
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -2184,7 +2184,7 @@ parse_relocation (char **str, bfd_reloc_
>        {
>         size_t len = 1 + strlen (percent_op->str);
>
> -       if (!ISSPACE ((*str)[len]) && (*str)[len] != '(')
> +       if (is_part_of_name ((*str)[len]))
>           continue;
>
>         *str += len;
> --- a/gas/testsuite/gas/riscv/auipc-parsing.d
> +++ b/gas/testsuite/gas/riscv/auipc-parsing.d
> @@ -1,3 +1,3 @@
> -#as:
> +#as: -al
>  #source: auipc-parsing.s
>  #error_output: auipc-parsing.l
> --- a/gas/testsuite/gas/riscv/auipc-parsing.l
> +++ b/gas/testsuite/gas/riscv/auipc-parsing.l
> @@ -3,3 +3,7 @@
>  .*: Error: illegal operands `lui x10,x11'
>  .*: Error: illegal operands `auipc x12,symbol'
>  .*: Error: illegal operands `lui x13,symbol'
> +#...
> + *[0-9]+[      ]+# Accept unary .*
> + *[0-9]+[      ]+\?\?\?\? 17070000[    ]+auipc x14,%hi \+symbol
> + *[0-9]+[      ]+\?\?\?\? B7B7CBED[    ]+lui   x15,%hi -0x12345678
> --- a/gas/testsuite/gas/riscv/auipc-parsing.s
> +++ b/gas/testsuite/gas/riscv/auipc-parsing.s
> @@ -4,3 +4,6 @@
>  # Don't accept a symbol without %hi() for 'u' operands.
>         auipc   x12,symbol
>         lui     x13,symbol
> +# Accept unary operators starting the subject expression.
> +       auipc   x14,%hi +symbol
> +       lui     x15,%hi -0x12345678
>
>


More information about the Binutils mailing list