public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] RISC-V: tighten post-relocation-operator separator expectation
@ 2023-05-04  8:24 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-05-04  8:24 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=654dfab0666513a4e9c053559d0c184b863139c4

commit 654dfab0666513a4e9c053559d0c184b863139c4
Author: Jan Beulich <jbeulich@suse.com>
Date:   Thu May 4 10:24:36 2023 +0200

    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.

Diff:
---
 gas/config/tc-riscv.c                   | 4 +++-
 gas/testsuite/gas/riscv/auipc-parsing.l | 2 ++
 gas/testsuite/gas/riscv/auipc-parsing.s | 3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index a94d4f69df6..0cc2484b049 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -2200,7 +2200,9 @@ parse_relocation (char **str, bfd_reloc_code_real_type *reloc,
       {
 	size_t len = 1 + strlen (percent_op->str);
 
-	if (!ISSPACE ((*str)[len]) && (*str)[len] != '(')
+	while (ISSPACE ((*str)[len]))
+	  ++len;
+	if ((*str)[len] != '(')
 	  continue;
 
 	*str += len;
diff --git a/gas/testsuite/gas/riscv/auipc-parsing.l b/gas/testsuite/gas/riscv/auipc-parsing.l
index 54eedcbf04f..2ea0f7c5826 100644
--- a/gas/testsuite/gas/riscv/auipc-parsing.l
+++ b/gas/testsuite/gas/riscv/auipc-parsing.l
@@ -3,3 +3,5 @@
 .*: Error: illegal operands `lui x10,x11'
 .*: Error: illegal operands `auipc x12,symbol'
 .*: Error: illegal operands `lui x13,symbol'
+.*: Error: illegal operands `auipc x14,%hi symbol'
+.*: Error: illegal operands `lui x15,%hi symbol'
diff --git a/gas/testsuite/gas/riscv/auipc-parsing.s b/gas/testsuite/gas/riscv/auipc-parsing.s
index 7af4df9ede1..c99f3de9cc1 100644
--- 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
+# Don't accept reloc functions without parentheses.
+	auipc	x14,%hi symbol
+	lui	x15,%hi symbol

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-04  8:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04  8:24 [binutils-gdb] RISC-V: tighten post-relocation-operator separator expectation Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).