public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
	Andrew Waterman <andrew@sifive.com>,
	Jim Wilson <jim.wilson.gcc@gmail.com>,
	Nelson Chu <nelson@rivosinc.com>
Subject: [PATCH] RISC-V: tighten post-relocation-operator separator expectation
Date: Fri, 28 Apr 2023 14:57:30 +0200	[thread overview]
Message-ID: <e1da592f-5c5b-418b-a25b-afeeb0691ea7@suse.com> (raw)

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

             reply	other threads:[~2023-04-28 12:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28 12:57 Jan Beulich [this message]
2023-05-04  8:16 ` Nelson Chu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1da592f-5c5b-418b-a25b-afeeb0691ea7@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew@sifive.com \
    --cc=binutils@sourceware.org \
    --cc=jim.wilson.gcc@gmail.com \
    --cc=nelson@rivosinc.com \
    --cc=palmer@dabbelt.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).