+2020-06-05 Nelson Chu <nelson.chu@sifive.com>
+
+ * 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.
+
2020-06-04 H.J. Lu <hongjiu.lu@intel.com>
* config/tc-ip2k. (ip2k_apply_fix): Pass endianness to
/* 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;
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0_xargle0p0"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0_xargle0p0_xfoo0p0"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32i2p0"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv64i2p0"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32e1p9"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32i2p1_m2p0_zicsr0p0"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
--- /dev/null
+#as: -march-attr
+#readelf: -A
+#source: attribute-11.s
+Attribute Section: riscv
+File Attributes
+ Tag_RISCV_arch: [a-zA-Z0-9_\"].*
+ Tag_RISCV_priv_spec: [0-9_\"].*
+#...
--- /dev/null
+ csrr a0, 0x0
--- /dev/null
+#as: -march-attr -mpriv-spec=1.9.1
+#readelf: -A
+#source: attribute-11.s
+Attribute Section: riscv
+File Attributes
+ Tag_RISCV_arch: [a-zA-Z0-9_\"].*
+ Tag_RISCV_priv_spec: 1
+ Tag_RISCV_priv_spec_minor: 9
+ Tag_RISCV_priv_spec_revision: 1
--- /dev/null
+#as: -march-attr -mpriv-spec=1.9.1
+#readelf: -A
+#source: empty.s
+Attribute Section: riscv
+File Attributes
+ Tag_RISCV_arch: [a-zA-Z0-9_\"].*
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: [a-zA-Z0-9_\"].*
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Tag_unknown_255: "test"
Tag_unknown_256: 123 \(0x7b\)
+2020-06-05 Nelson Chu <nelson.chu@sifive.com>
+
+ * testsuite/ld-riscv-elf/attr-merge-arch-01.d: The CSR isn't used,
+ so ignore the -mpriv-spec setting.
+ * 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.
+
2020-06-04 H.J. Lu <hongjiu.lu@intel.com>
PR ld/26080
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32i2p0_m2p0"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32i2p0_m2p0"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv32i2p0_m2p0_xbar2p0_xfoo2p0"
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
File Attributes
Tag_RISCV_stack_align: 16-bytes
Tag_RISCV_arch: [a-zA-Z0-9_\"].*
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
#...
File Attributes
Tag_RISCV_arch: [a-zA-Z0-9_\"].*
Tag_RISCV_unaligned_access: Unaligned access
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
File Attributes
Tag_RISCV_arch: [a-zA-Z0-9_\"].*
Tag_RISCV_unaligned_access: Unaligned access
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
File Attributes
Tag_RISCV_arch: [a-zA-Z0-9_\"].*
Tag_RISCV_unaligned_access: Unaligned access
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: [a-zA-Z0-9_\"].*
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
File Attributes
Tag_RISCV_arch: [a-zA-Z0-9_\"].*
Tag_RISCV_unaligned_access: Unaligned access
- Tag_RISCV_priv_spec: [0-9_\"].*
- Tag_RISCV_priv_spec_minor: [0-9_\"].*
-#...
#source: call-relax-1.s
#source: call-relax-2.s
#source: call-relax-3.s
-#as: -march=rv32ic
+#as: -march=rv32ic -mno-arch-attr
#ld: -melf32lriscv
#objdump: -d
#pass