RISC-V: tighten post-relocation-operator separator expectation

As per the spec merely a blank isn't okay as a separator, the operand
to the relocation function ought to be parenthesized. Enforcing this
then also eliminates an inconsistency in that

	lui	t0, %hi sym
	lui	t0, %hi 0x1000

were accepted, but

	lui	t0, %hi +sym
	lui	t0, %hi -0x1000

were not.
This commit is contained in:
Jan Beulich 2023-05-04 10:24:36 +02:00
parent c981907770
commit 654dfab066
3 changed files with 8 additions and 1 deletions

View File

@ -2200,7 +2200,9 @@ parse_relocation (char **str, bfd_reloc_code_real_type *reloc,
{ {
size_t len = 1 + strlen (percent_op->str); size_t len = 1 + strlen (percent_op->str);
if (!ISSPACE ((*str)[len]) && (*str)[len] != '(') while (ISSPACE ((*str)[len]))
++len;
if ((*str)[len] != '(')
continue; continue;
*str += len; *str += len;

View File

@ -3,3 +3,5 @@
.*: Error: illegal operands `lui x10,x11' .*: Error: illegal operands `lui x10,x11'
.*: Error: illegal operands `auipc x12,symbol' .*: Error: illegal operands `auipc x12,symbol'
.*: Error: illegal operands `lui x13,symbol' .*: Error: illegal operands `lui x13,symbol'
.*: Error: illegal operands `auipc x14,%hi symbol'
.*: Error: illegal operands `lui x15,%hi symbol'

View File

@ -4,3 +4,6 @@
# Don't accept a symbol without %hi() for 'u' operands. # Don't accept a symbol without %hi() for 'u' operands.
auipc x12,symbol auipc x12,symbol
lui x13,symbol lui x13,symbol
# Don't accept reloc functions without parentheses.
auipc x14,%hi symbol
lui x15,%hi symbol