1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- From 537d1469b43f7c60cbdd196727afd186951a1286 Mon Sep 17 00:00:00 2001
- From: Nelson Chu <nelson.chu@sifive.com>
- Date: Sat, 21 Nov 2020 11:19:58 +0800
- Subject: [PATCH 05/48] RISC-V: Don't allow any uppercase letter in the arch
- string.
- 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/elfxx-riscv.c | 14 +++++++++++++-
- .../gas/riscv/march-fail-uppercase-base.d | 2 +-
- gas/testsuite/gas/riscv/march-fail-uppercase-x.d | 3 +++
- gas/testsuite/gas/riscv/march-fail-uppercase.l | 2 +-
- 4 files changed, 18 insertions(+), 3 deletions(-)
- create mode 100644 gas/testsuite/gas/riscv/march-fail-uppercase-x.d
- diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
- index dc196e0e12..d29bb0375e 100644
- --- a/bfd/elfxx-riscv.c
- +++ b/bfd/elfxx-riscv.c
- @@ -1495,9 +1495,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;
- diff --git a/gas/testsuite/gas/riscv/march-fail-uppercase-base.d b/gas/testsuite/gas/riscv/march-fail-uppercase-base.d
- index 74b55ea165..8b595856b4 100644
- --- a/gas/testsuite/gas/riscv/march-fail-uppercase-base.d
- +++ b/gas/testsuite/gas/riscv/march-fail-uppercase-base.d
- @@ -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
- index 0000000000..316351fce8
- --- /dev/null
- +++ b/gas/testsuite/gas/riscv/march-fail-uppercase-x.d
- @@ -0,0 +1,3 @@
- +#as: -march=rv32ic_zicsr_xARGLE
- +#source: empty.s
- +#error_output: march-fail-uppercase.l
- diff --git a/gas/testsuite/gas/riscv/march-fail-uppercase.l b/gas/testsuite/gas/riscv/march-fail-uppercase.l
- index 2053135922..292c18adcc 100644
- --- a/gas/testsuite/gas/riscv/march-fail-uppercase.l
- +++ b/gas/testsuite/gas/riscv/march-fail-uppercase.l
- @@ -1,2 +1,2 @@
- .*Assembler messages:
- -.*Fatal error: .*unknown (standard|z) ISA extension.*
- +.*Fatal error: .*ISA string cannot contain uppercase letters
- --
- 2.33.0
|