aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorNelson Chu <nelson.chu@sifive.com>2020-05-29 15:31:46 +0800
committerNelson Chu <nelson.chu@sifive.com>2020-06-05 12:14:44 +0800
commit3fc6c3dc2af2283bd89f1b1278b39922416e8d1b (patch)
tree6c08c01a0b1b35f343db32e2093c01b8abd59923 /gas/config
parenta975c88e6549c508ec86658e6816d7b8f16af13c (diff)
downloadfsf-binutils-gdb-3fc6c3dc2af2283bd89f1b1278b39922416e8d1b.zip
fsf-binutils-gdb-3fc6c3dc2af2283bd89f1b1278b39922416e8d1b.tar.gz
fsf-binutils-gdb-3fc6c3dc2af2283bd89f1b1278b39922416e8d1b.tar.bz2
RISC-V: Don't generate the ELF privilege attributes when no CSR are used.
gas/ * config/tc-riscv.c (explicit_csr): New static boolean. Used to indicate CSR are explictly used. (riscv_ip): Set explicit_csr to TRUE if any CSR is used. (riscv_write_out_attrs): If we already have set elf priv attributes, then generate them. Otherwise, don't generate them when no CSR are used. * testsuite/gas/riscv/attribute-01.d: Remove the priv attributes. * testsuite/gas/riscv/attribute-02.d: Likewise. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/attribute-04.d: Likewise. * testsuite/gas/riscv/attribute-05.d: Likewise. * testsuite/gas/riscv/attribute-06.d: Likewise. * testsuite/gas/riscv/attribute-07.d: Likewise. * testsuite/gas/riscv/attribute-08.d: Likewise. * testsuite/gas/riscv/attribute-09.d: Likewise. * testsuite/gas/riscv/attribute-10.d: Likewise. * testsuite/gas/riscv/attribute-unknown.d: Likewise. * testsuite/gas/riscv/attribute-11.s: New testcase. * testsuite/gas/riscv/attribute-11.d: New testcase. The CSR is used, so we should output the ELF priv attributes. * testsuite/gas/riscv/attribute-12.d: New testcase. The CSR is used, so output the priv attributes according to the -mpriv-spec. * testsuite/gas/riscv/attribute-13.d: New testcase. The CSR isn't used, so ignore the -mpriv-spec setting. ld/ * testsuite/ld-riscv-elf/attr-merge-arch-01.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-stack-align.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-01.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-04.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-05.d: Likewise. * testsuite/ld-riscv-elf/call-relax.d: Add -mno-arch-attr.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-riscv.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index da94b5b..cc77dbf 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -374,6 +374,9 @@ static bfd_boolean start_assemble = FALSE;
/* Indicate ELF attributes are explictly set. */
static bfd_boolean explicit_attr = FALSE;
+/* Indicate CSR are explictly used. */
+static bfd_boolean explicit_csr = FALSE;
+
/* Macros for encoding relaxation state for RVC branches and far jumps. */
#define RELAX_BRANCH_ENCODE(uncond, rvc, length) \
((relax_substateT) \
@@ -2212,6 +2215,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
case 'E': /* Control register. */
insn_with_csr = TRUE;
+ explicit_csr = TRUE;
if (reg_lookup (&s, RCLASS_CSR, &regno))
INSERT_OPERAND (CSR, *ip, regno);
else
@@ -3605,6 +3609,11 @@ riscv_write_out_attrs (void)
&& !riscv_set_default_priv_spec (NULL))
return;
+ /* If we already have set elf priv attributes, then generate them.
+ Otherwise, don't generate them when no CSR are used. */
+ if (!explicit_csr)
+ return;
+
/* Re-write priv attributes by default_priv_spec. */
priv_str = riscv_get_priv_spec_name (default_priv_spec);
p = priv_str;