public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: tighten post-relocation-operator separator expectation
@ 2023-04-28 12:57 Jan Beulich
  2023-05-04  8:16 ` Nelson Chu
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2023-04-28 12:57 UTC (permalink / raw)
  To: Binutils; +Cc: Palmer Dabbelt, Andrew Waterman, Jim Wilson, Nelson Chu

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.

--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -2200,7 +2200,9 @@ parse_relocation (char **str, bfd_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;
--- 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'
--- 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] 2+ messages in thread

end of thread, other threads:[~2023-05-04  8:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-28 12:57 [PATCH] RISC-V: tighten post-relocation-operator separator expectation Jan Beulich
2023-05-04  8:16 ` Nelson Chu

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).