public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Kito Cheng <kito.cheng@gmail.com>
To: patches@groups.riscv.org
Cc: binutils@sourceware.org, Ana Pazos <apazos@codeaurora.org>,
		Alex Bradbury <asb@lowrisc.org>
Subject: Re: [patches] Re: [PATCH] RISC-V: Reject empty rouding mode and fence operand.
Date: Wed, 22 Aug 2018 01:29:00 -0000	[thread overview]
Message-ID: <CA+yXCZCEQ0EpNBV04a4=uwTF5Jn1Jb+o-KQzX_MKPJhmaOdACg@mail.gmail.com> (raw)
In-Reply-To: <CAFyWVabKZpw6g4P8Dq_1MMKCLv1yemTsNH6hQ=FbKndKL0omkg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1607 bytes --]

Hi Jim:

Oh, my mistake..., patch attached.




gas/ChangeLog

2018-08-21  Kito Cheng  <kito@andestech.com>

        * config/tc-riscv.c (arg_lookup): Checking
        length before look up.
        * testsuite/gas/riscv/fence-fail.d: New file.
        * testsuite/gas/riscv/fence-fail.l: Likewise.
        * testsuite/gas/riscv/fence-fail.s: Likewise.
        * testsuite/gas/riscv/rouding-fail.d: Likewise.
        * testsuite/gas/riscv/rouding-fail.l: Likewise.
        * testsuite/gas/riscv/rouding-fail.s: Likewise.
On Wed, Aug 22, 2018 at 1:59 AM Jim Wilson <jimw@sifive.com> wrote:
>
> On Tue, Aug 21, 2018 at 8:53 AM, Kito Cheng <kito.cheng@gmail.com> wrote:
> > Current assembler will accept empty operand for fence and rounding
> > mode, such as "fence ," or "fadd.s fa1,fa1,fa1,", it cause by strncmp
> > with zero length in arg_lookup function.
>
> There is a ChangeLog entry but no patch.
>
> There is a typo in the ChangeLog entry
> lenght -> length
>
> Jim
>
> --
> You received this message because you are subscribed to the Google Groups "RISC-V Patches" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to patches+unsubscribe@groups.riscv.org.
> To post to this group, send email to patches@groups.riscv.org.
> Visit this group at https://groups.google.com/a/groups.riscv.org/group/patches/.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/patches/CAFyWVabKZpw6g4P8Dq_1MMKCLv1yemTsNH6hQ%3DFbKndKL0omkg%40mail.gmail.com.
> For more options, visit https://groups.google.com/a/groups.riscv.org/d/optout.

[-- Attachment #2: 0001-RISC-V-Reject-empty-rouding-mode-and-fence-operand.patch --]
[-- Type: application/octet-stream, Size: 3792 bytes --]

From db5ba68aadbb0d4ccf2070f2de3796534870ef80 Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng@gmail.com>
Date: Mon, 20 Aug 2018 11:58:39 +0800
Subject: [PATCH] RISC-V: Reject empty rouding mode and fence operand.

This patch checking the operand lenght before matching the operand
table, in order to prevent empty operand matching everything.

gas/ChangeLog

2018-08-21  Kito Cheng  <kito@andestech.com>

	* config/tc-riscv.c (arg_lookup): Checking
	length before look up.
	* testsuite/gas/riscv/fence-fail.d: New file.
	* testsuite/gas/riscv/fence-fail.l: Likewise.
	* testsuite/gas/riscv/fence-fail.s: Likewise.
	* testsuite/gas/riscv/rouding-fail.d: Likewise.
	* testsuite/gas/riscv/rouding-fail.l: Likewise.
	* testsuite/gas/riscv/rouding-fail.s: Likewise.
---
 gas/config/tc-riscv.c                  | 3 +++
 gas/testsuite/gas/riscv/fence-fail.d   | 3 +++
 gas/testsuite/gas/riscv/fence-fail.l   | 4 ++++
 gas/testsuite/gas/riscv/fence-fail.s   | 4 ++++
 gas/testsuite/gas/riscv/rouding-fail.d | 3 +++
 gas/testsuite/gas/riscv/rouding-fail.l | 3 +++
 gas/testsuite/gas/riscv/rouding-fail.s | 3 +++
 7 files changed, 23 insertions(+)
 create mode 100644 gas/testsuite/gas/riscv/fence-fail.d
 create mode 100644 gas/testsuite/gas/riscv/fence-fail.l
 create mode 100644 gas/testsuite/gas/riscv/fence-fail.s
 create mode 100644 gas/testsuite/gas/riscv/rouding-fail.d
 create mode 100644 gas/testsuite/gas/riscv/rouding-fail.l
 create mode 100644 gas/testsuite/gas/riscv/rouding-fail.s

diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 5ba997e6ca..ee4b4f5b7e 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -618,6 +618,9 @@ arg_lookup (char **s, const char *const *array, size_t size, unsigned *regnop)
   const char *p = strchr (*s, ',');
   size_t i, len = p ? (size_t)(p - *s) : strlen (*s);
 
+  if (len == 0)
+    return FALSE;
+
   for (i = 0; i < size; i++)
     if (array[i] != NULL && strncmp (array[i], *s, len) == 0)
       {
diff --git a/gas/testsuite/gas/riscv/fence-fail.d b/gas/testsuite/gas/riscv/fence-fail.d
new file mode 100644
index 0000000000..05b158fd75
--- /dev/null
+++ b/gas/testsuite/gas/riscv/fence-fail.d
@@ -0,0 +1,3 @@
+#as: -march=rv32i
+#source: fence-fail.s
+#error-output: fence-fail.l
diff --git a/gas/testsuite/gas/riscv/fence-fail.l b/gas/testsuite/gas/riscv/fence-fail.l
new file mode 100644
index 0000000000..0d0912d5a9
--- /dev/null
+++ b/gas/testsuite/gas/riscv/fence-fail.l
@@ -0,0 +1,4 @@
+.*: Assembler messages:
+.*: Error: illegal operands `fence ,'
+.*: Error: illegal operands `fence w,'
+.*: Error: illegal operands `fence ,w'
diff --git a/gas/testsuite/gas/riscv/fence-fail.s b/gas/testsuite/gas/riscv/fence-fail.s
new file mode 100644
index 0000000000..9ce460ecfa
--- /dev/null
+++ b/gas/testsuite/gas/riscv/fence-fail.s
@@ -0,0 +1,4 @@
+target:
+	fence ,
+	fence w,
+	fence ,w
diff --git a/gas/testsuite/gas/riscv/rouding-fail.d b/gas/testsuite/gas/riscv/rouding-fail.d
new file mode 100644
index 0000000000..3544507e8b
--- /dev/null
+++ b/gas/testsuite/gas/riscv/rouding-fail.d
@@ -0,0 +1,3 @@
+#as: -march=rv32ifd
+#source: rouding-fail.s
+#error-output: rouding-fail.l
diff --git a/gas/testsuite/gas/riscv/rouding-fail.l b/gas/testsuite/gas/riscv/rouding-fail.l
new file mode 100644
index 0000000000..ea46e7c2d5
--- /dev/null
+++ b/gas/testsuite/gas/riscv/rouding-fail.l
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*: Error: illegal operands `fadd.s fa1,fa1,fa1,'
+.*: Error: illegal operands `fadd.d fa1,fa1,fa1,'
diff --git a/gas/testsuite/gas/riscv/rouding-fail.s b/gas/testsuite/gas/riscv/rouding-fail.s
new file mode 100644
index 0000000000..d18f53efb5
--- /dev/null
+++ b/gas/testsuite/gas/riscv/rouding-fail.s
@@ -0,0 +1,3 @@
+target:
+	fadd.s fa1,fa1,fa1,
+	fadd.d fa1,fa1,fa1,
-- 
2.17.1


  reply	other threads:[~2018-08-22  1:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-21 15:54 Kito Cheng
2018-08-21 17:59 ` Jim Wilson
2018-08-22  1:29   ` Kito Cheng [this message]
2018-08-23 20:31     ` [patches] " Jim Wilson

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='CA+yXCZCEQ0EpNBV04a4=uwTF5Jn1Jb+o-KQzX_MKPJhmaOdACg@mail.gmail.com' \
    --to=kito.cheng@gmail.com \
    --cc=apazos@codeaurora.org \
    --cc=asb@lowrisc.org \
    --cc=binutils@sourceware.org \
    --cc=patches@groups.riscv.org \
    /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).