/* 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) \
case 'E': /* Control register. */
insn_with_csr = TRUE;
+ explicit_csr = TRUE;
if (reg_lookup (&s, RCLASS_CSR, ®no))
INSERT_OPERAND (CSR, *ip, regno);
else
&& !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;