RISC-V: Don't allow any uppercase letter in the arch string.
authorNelson Chu <nelson.chu@sifive.com>
Sat, 21 Nov 2020 03:19:58 +0000 (11:19 +0800)
committerNelson Chu <nelson.chu@sifive.com>
Tue, 1 Dec 2020 07:09:26 +0000 (15:09 +0800)
Although I cannot find any RISC-V specs said that uppercases are not
allowed in the arhc string, but seems like it is an established fact
both for GNU and LLVM.  Therefore, we shouldn't allow the uppercases
for the non-standard x extensions, too.

bfd/
* elfxx-riscv.c (riscv_parse_subset): ISA string cannot contain
any uppercase letter.

gas/
* testsuite/gas/riscv/march-fail-uppercase-base.d: Updated.
* testsuite/gas/riscv/march-fail-uppercase.l: Updated.
* testsuite/gas/riscv/march-fail-uppercase-x.d: New testcase.

bfd/ChangeLog
bfd/elfxx-riscv.c
gas/ChangeLog
gas/testsuite/gas/riscv/march-fail-uppercase-base.d
gas/testsuite/gas/riscv/march-fail-uppercase-x.d [new file with mode: 0644]
gas/testsuite/gas/riscv/march-fail-uppercase.l

index 4c6c6941591b3a41f4fcf11c6f9c83850204e104..3ac27196bdc4e9a177975c04245782e9aaa91b9e 100644 (file)
@@ -1,3 +1,8 @@
+2020-12-01  Nelson Chu  <nelson.chu@sifive.com>
+
+       * elfxx-riscv.c (riscv_parse_subset): ISA string cannot contain
+       any uppercase letter.
+
 2020-12-01  Nelson Chu  <nelson.chu@sifive.com>
 
        * elfxx-riscv.c: Re-indent codes, unify and improve the error
index 5ed8aa088a2d96bdfa9144e58783934efb2bbea0..69f3a4353b9361596afe63a5ee92e999c82c6eea 100644 (file)
@@ -1510,9 +1510,21 @@ bfd_boolean
 riscv_parse_subset (riscv_parse_subset_t *rps,
                    const char *arch)
 {
-  const char *p = arch;
+  const char *p;
   size_t i;
 
+  for (p = arch; *p != '\0'; p++)
+    {
+      if (ISUPPER (*p))
+       {
+         rps->error_handler
+           (_("-march=%s: ISA string cannot contain uppercase letters"),
+            arch);
+         return FALSE;
+       }
+    }
+
+  p = arch;
   if (strncmp (p, "rv32", 4) == 0)
     {
       *rps->xlen = 32;
index 6ab777eb82d161807a839cd74fee948db3f920b5..2a2b593a13f7ba7cd0d496cc9dc2183538fe6fdf 100644 (file)
@@ -1,3 +1,9 @@
+2020-12-01  Nelson Chu  <nelson.chu@sifive.com>
+
+       * testsuite/gas/riscv/march-fail-uppercase-base.d: Updated.
+       * testsuite/gas/riscv/march-fail-uppercase.l: Updated.
+       * testsuite/gas/riscv/march-fail-uppercase-x.d: New testcase.
+
 2020-12-01  Nelson Chu  <nelson.chu@sifive.com>
 
        (These are new testcases that cover more cases)
index 74b55ea165eb73e3467e332d0b01ad08e7d26263..8b595856b4c4002f6df9c093fe7d3402050e8422 100644 (file)
@@ -1,3 +1,3 @@
 #as: -march=rv32I
 #source: empty.s
-#error_output: march-fail-base-01.l
+#error_output: march-fail-uppercase.l
diff --git a/gas/testsuite/gas/riscv/march-fail-uppercase-x.d b/gas/testsuite/gas/riscv/march-fail-uppercase-x.d
new file mode 100644 (file)
index 0000000..316351f
--- /dev/null
@@ -0,0 +1,3 @@
+#as: -march=rv32ic_zicsr_xARGLE
+#source: empty.s
+#error_output: march-fail-uppercase.l
index 20531359228f3764c5a651cc9c56f88d328bff84..292c18adcc6499e839e1e36d2c82fe20de6af218 100644 (file)
@@ -1,2 +1,2 @@
 .*Assembler messages:
-.*Fatal error: .*unknown (standard|z) ISA extension.*
+.*Fatal error: .*ISA string cannot contain uppercase letters
This page took 0.036177 seconds and 4 git commands to generate.