public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues
@ 2020-08-20  6:34 Nelson Chu
  2020-08-20  6:34 ` [PATCH 1/3] RISC-V: Improve the error message for the mis-matched ISA versions Nelson Chu
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Nelson Chu @ 2020-08-20  6:34 UTC (permalink / raw)
  To: binutils; +Cc: jimw, kito.cheng, nelson.chu

Hi binutils,

There are three patches used to fix some minor issues when linker merging
ELF attributes.

* The first patch from Kito cheng fixs the wrong error reports when the ISA
versions are mis-matched.  Consider the following case,

$ cat a.s
.attribute arch, "rv64i2p0_m2p0_a2p0"
$ cat b.s
.attribute arch, "rv64i2p0_m2p0_a3p0"
$ riscv64-unknown-elf-as a.s -o a.o
$ riscv64-unknown-elf-as b.s -o b.o
$ riscv64-unknown-elf-ld -r a.o b.o
riscv64-unknown-elf-ld: error: b.o: Mis-matched ISA version for 'm' extension. 2.0 vs 2.0
riscv64-unknown-elf-ld: failed to merge target specific data of file b.o

But the mis-matched ISA should be 'a' rather than 'm'.  This patch will fix
the wrong message.

$ riscv64-unknown-elf-ld-new -r a.o b.o
riscv64-unknown-elf-ld: error: b.o: Mis-matched ISA version for 'a' extension. 3.0 vs 2.0

* The second patch allows to link objects with different versions of ISA.
The different ISA versions should be compatible, unless there are some known
conflicts.  Same as what the privileged spec attributes did, report warnings
for those different ISA versions are merged should be enough.  So the above
mis-matched errors will be changed to warnings,

$ riscv64-unknown-elf-ld-new -r a.o b.o
riscv64-unknown-elf-ld: warning: b.o: Mis-matched ISA version 3.0 for 'a' extension, the output version is 2.0.

* And the third patch just fixs typos amd do some minor cleanups when merging priv spec attributes.

Thanks
Nelson


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] RISC-V: Improve the error message for the mis-matched ISA versions.
  2020-08-20  6:34 [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues Nelson Chu
@ 2020-08-20  6:34 ` Nelson Chu
  2020-08-20  6:34 ` [PATCH 2/3] RISC-V: Report warnings rather than errors " Nelson Chu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Nelson Chu @ 2020-08-20  6:34 UTC (permalink / raw)
  To: binutils; +Cc: jimw, kito.cheng, nelson.chu

From: Kito Cheng <kito.cheng@sifive.com>

Consider the updated attr-merge-arch-failed-01.d testcase.  Extension
A's version are mis-matched between attr-merge-arch-failed-01a.s and
attr-merge-arch-failed-01b.s.  But the old binutils reports that the
mis-matched extension is M rather than A.  This commit is used to fix
the wrong mis-matched error message.

Besides, when parsing the arch string in the riscv_parse_subset, it
shouldn't be NULL or empty.  However, it might be empty when we failed
to merge the arch string in the riscv_merge_attributes.  Since we should
already issue the correct error message in another side, and the message
- ISA string must begin with rv32 or rv64 - is meaninglesss when the arch
string is empty, so do not issue it.

	bfd/
	* elfnn-riscv.c (riscv_merge_std_ext): Fix to report the correct
	error message when the versions of extension are mis-matched.
	* elfxx-riscv.c (riscv_parse_subset): Don't issue the error when
	the string is empty.

	ld/
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s: Likewise.
---
 bfd/elfnn-riscv.c                                      |  2 +-
 bfd/elfxx-riscv.c                                      | 12 +++++++++---
 ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d  |  2 +-
 ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s |  2 +-
 ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s |  2 +-
 5 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index fb78c24..aa0141b 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -2722,7 +2722,7 @@ riscv_merge_std_ext (bfd *ibfd,
 	  && ((find_in->major_version != find_out->major_version)
 	      || (find_in->minor_version != find_out->minor_version)))
 	{
-	  riscv_version_mismatch (ibfd, in, out);
+	  riscv_version_mismatch (ibfd, find_in, find_out);
 	  return FALSE;
 	}
 
diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 1570f1d..cfdd867 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1519,9 +1519,15 @@ riscv_parse_subset (riscv_parse_subset_t *rps,
     }
   else
     {
-      rps->error_handler
-	(_("-march=%s: ISA string must begin with rv32 or rv64"),
-	 arch);
+      /* Arch string shouldn't be NULL or empty here.  However,
+	 it might be empty only when we failed to merge the arch
+	 string in the riscv_merge_attributes.  We have already
+	 issued the correct error message in another side, so do
+	 not issue this error when the arch string is empty.  */
+      if (strlen (arch))
+	rps->error_handler (
+	  _("-march=%s: ISA string must begin with rv32 or rv64"),
+	  arch);
       return FALSE;
     }
 
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d
index c77f80b..8a9c092 100644
--- a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d
@@ -2,4 +2,4 @@
 #source: attr-merge-arch-failed-01b.s
 #as: -march-attr
 #ld: -r -melf32lriscv
-#error: Mis-matched ISA version for 'm' extension. 3.0 vs 2.0
+#error: Mis-matched ISA version for 'a' extension. 3.0 vs 2.0
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s
index acc98a5..365901d 100644
--- a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s
@@ -1 +1 @@
-	.attribute arch, "rv32i2p0_m2p0"
+	.attribute arch, "rv32i2p0_m2p0_a2p0"
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s
index c9a590a..49263bf 100644
--- a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s
@@ -1 +1 @@
-	.attribute arch, "rv32i2p0_m3p0"
+	.attribute arch, "rv32i2p0_m2p0_a3p0"
-- 
2.7.4


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/3] RISC-V: Report warnings rather than errors for the mis-matched ISA versions.
  2020-08-20  6:34 [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues Nelson Chu
  2020-08-20  6:34 ` [PATCH 1/3] RISC-V: Improve the error message for the mis-matched ISA versions Nelson Chu
@ 2020-08-20  6:34 ` Nelson Chu
  2020-08-20  6:34 ` [PATCH 3/3] RISC-V: Minor cleanup and typos when merging priv spec attributes Nelson Chu
  2020-08-25 17:13 ` [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues Palmer Dabbelt
  3 siblings, 0 replies; 8+ messages in thread
From: Nelson Chu @ 2020-08-20  6:34 UTC (permalink / raw)
  To: binutils; +Cc: jimw, kito.cheng, nelson.chu

Same as the privileged spec attributes check - different ISA versions
should be compatible, unless there are some known conflicts.  Therefore,
we should allow to link objects with different ISA versions, and update
the output ISA versions once the corresponding input ones are newer.
But it's better to also warn people that the conflicts may happen when
the ISA versions are mis-matched.

	bfd/
	* elfnn-riscv.c (riscv_version_mismatch): Change the return type
	from void to bfd_boolean.  Report warnings rather than errors
	when the ISA versions are mis-matched.  Afterwards, remember to
	update the output ISA versions to the newest ones.
	(riscv_merge_std_ext): Allow to link objects with different
	standard ISA versions.  Try to add output ISA versions to
	merged_subsets first.
	(riscv_merge_multi_letter_ext): Likewise.  But for standard sub
	ISA and non-standard ISA versions.

	ld/
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Update the
	message from error to warning.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d: New testcases.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-02a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-02b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-02c.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-failed-02d.s: Likewise.
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
---
 bfd/elfnn-riscv.c                                  | 71 ++++++++++++----------
 .../ld-riscv-elf/attr-merge-arch-failed-01.d       |  8 ++-
 .../ld-riscv-elf/attr-merge-arch-failed-02.d       | 27 ++++++++
 .../ld-riscv-elf/attr-merge-arch-failed-02a.s      |  1 +
 .../ld-riscv-elf/attr-merge-arch-failed-02b.s      |  1 +
 .../ld-riscv-elf/attr-merge-arch-failed-02c.s      |  1 +
 .../ld-riscv-elf/attr-merge-arch-failed-02d.s      |  1 +
 ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp         |  1 +
 8 files changed, 78 insertions(+), 33 deletions(-)
 create mode 100644 ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d
 create mode 100644 ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02a.s
 create mode 100644 ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02b.s
 create mode 100644 ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02c.s
 create mode 100644 ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02d.s

diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index aa0141b..513785e 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -2616,19 +2616,42 @@ riscv_std_ext_p (const char *name)
   return (strlen (name) == 1) && (name[0] != 'x') && (name[0] != 's');
 }
 
-/* Error handler when version mis-match.  */
+/* Check if the versions are compatible.  */
 
-static void
+static bfd_boolean
 riscv_version_mismatch (bfd *ibfd,
 			struct riscv_subset_t *in,
 			struct riscv_subset_t *out)
 {
-  _bfd_error_handler
-    (_("error: %pB: Mis-matched ISA version for '%s' extension. "
-       "%d.%d vs %d.%d"),
-       ibfd, in->name,
-       in->major_version, in->minor_version,
-       out->major_version, out->minor_version);
+  if (in == NULL || out == NULL)
+    return TRUE;
+
+  /* Since there are no version conflicts for now, we just report
+     warning when the versions are mis-matched.  */
+  if (in->major_version != out->major_version
+      || in->minor_version != out->minor_version)
+    {
+      _bfd_error_handler
+	(_("warning: %pB: Mis-matched ISA version %d.%d for '%s' "
+	   "extension, the output version is %d.%d."),
+	 ibfd,
+	 in->major_version,
+	 in->minor_version,
+	 in->name,
+	 out->major_version,
+	 out->minor_version);
+
+      /* Update the output ISA versions to the newest ones.  */
+      if ((in->major_version > out->major_version)
+	  || (in->major_version == out->major_version
+	      && in->minor_version > out->minor_version))
+	{
+	  out->major_version = in->major_version;
+	  out->minor_version = in->minor_version;
+	}
+    }
+
+  return TRUE;
 }
 
 /* Return true if subset is 'i' or 'e'.  */
@@ -2690,16 +2713,11 @@ riscv_merge_std_ext (bfd *ibfd,
 	 ibfd, in->name, out->name);
       return FALSE;
     }
-  else if ((in->major_version != out->major_version) ||
-	   (in->minor_version != out->minor_version))
-    {
-      /* TODO: Allow different merge policy.  */
-      riscv_version_mismatch (ibfd, in, out);
-      return FALSE;
-    }
+  else if (!riscv_version_mismatch (ibfd, in, out))
+    return FALSE;
   else
     riscv_add_subset (&merged_subsets,
-		      in->name, in->major_version, in->minor_version);
+		      out->name, out->major_version, out->minor_version);
 
   in = in->next;
   out = out->next;
@@ -2716,17 +2734,10 @@ riscv_merge_std_ext (bfd *ibfd,
       if (find_in == NULL && find_out == NULL)
 	continue;
 
-      /* Check version is same or not.  */
-      /* TODO: Allow different merge policy.  */
-      if ((find_in != NULL && find_out != NULL)
-	  && ((find_in->major_version != find_out->major_version)
-	      || (find_in->minor_version != find_out->minor_version)))
-	{
-	  riscv_version_mismatch (ibfd, find_in, find_out);
-	  return FALSE;
-	}
+      if (!riscv_version_mismatch (ibfd, find_in, find_out))
+	return FALSE;
 
-      struct riscv_subset_t *merged = find_in ? find_in : find_out;
+      struct riscv_subset_t *merged = find_out ? find_out : find_in;
       riscv_add_subset (&merged_subsets, merged->name,
 			merged->major_version, merged->minor_version);
     }
@@ -2810,12 +2821,8 @@ riscv_merge_multi_letter_ext (bfd *ibfd,
       else
 	{
 	  /* Both present, check version and increment both.  */
-	  if ((in->major_version != out->major_version)
-	      || (in->minor_version != out->minor_version))
-	    {
-	      riscv_version_mismatch (ibfd, in, out);
-	      return FALSE;
-	    }
+	  if (!riscv_version_mismatch (ibfd, in, out))
+	    return FALSE;
 
 	  riscv_add_subset (&merged_subsets, out->name, out->major_version,
 			    out->minor_version);
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d
index 8a9c092..435e827 100644
--- a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d
@@ -2,4 +2,10 @@
 #source: attr-merge-arch-failed-01b.s
 #as: -march-attr
 #ld: -r -melf32lriscv
-#error: Mis-matched ISA version for 'a' extension. 3.0 vs 2.0
+#warning: .*Mis-matched ISA version 3.0 for 'a' extension, the output version is 2.0.
+#readelf: -A
+
+Attribute Section: riscv
+File Attributes
+  Tag_RISCV_arch: ".*a3p0.*"
+#..
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d
new file mode 100644
index 0000000..3e43f68
--- /dev/null
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d
@@ -0,0 +1,27 @@
+#source: attr-merge-arch-failed-02a.s
+#source: attr-merge-arch-failed-02b.s
+#source: attr-merge-arch-failed-02c.s
+#source: attr-merge-arch-failed-02d.s
+#as: -march-attr
+#ld: -r -melf32lriscv
+#warning: .*Mis-matched ISA version 3.0 for 'i' extension, the output version is 2.0.
+#warning: .*Mis-matched ISA version 3.0 for 'm' extension, the output version is 2.0.
+#warning: .*Mis-matched ISA version 3.0 for 'a' extension, the output version is 2.0.
+#warning: .*Mis-matched ISA version 3.0 for 'zicsr' extension, the output version is 2.0.
+#warning: .*Mis-matched ISA version 3.0 for 'xunknown' extension, the output version is 2.0.
+#warning: .*Mis-matched ISA version 2.1 for 'i' extension, the output version is 3.0.
+#warning: .*Mis-matched ISA version 2.2 for 'm' extension, the output version is 3.0.
+#warning: .*Mis-matched ISA version 2.3 for 'a' extension, the output version is 3.0.
+#warning: .*Mis-matched ISA version 2.4 for 'zicsr' extension, the output version is 3.0.
+#warning: .*Mis-matched ISA version 2.5 for 'xunknown' extension, the output version is 3.0.
+#warning: .*Mis-matched ISA version 4.6 for 'i' extension, the output version is 3.0.
+#warning: .*Mis-matched ISA version 4.7 for 'm' extension, the output version is 3.0.
+#warning: .*Mis-matched ISA version 4.8 for 'a' extension, the output version is 3.0.
+#warning: .*Mis-matched ISA version 4.9 for 'zicsr' extension, the output version is 3.0.
+#warning: .*Mis-matched ISA version 4.0 for 'xunknown' extension, the output version is 3.0.
+#readelf: -A
+
+Attribute Section: riscv
+File Attributes
+  Tag_RISCV_arch: "rv32i4p6_m4p7_a4p8_zicsr4p9_xunknown4p0"
+#..
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02a.s b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02a.s
new file mode 100644
index 0000000..3dbf8a2
--- /dev/null
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02a.s
@@ -0,0 +1 @@
+	.attribute arch, "rv32i2p0_m2p0_a2p0_zicsr2p0_xunknown2p0"
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02b.s b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02b.s
new file mode 100644
index 0000000..7bbc39f
--- /dev/null
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02b.s
@@ -0,0 +1 @@
+	.attribute arch, "rv32i3p0_m3p0_a3p0_zicsr3p0_xunknown3p0"
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02c.s b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02c.s
new file mode 100644
index 0000000..2a921e6
--- /dev/null
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02c.s
@@ -0,0 +1 @@
+	.attribute arch, "rv32i2p1_m2p2_a2p3_zicsr2p4_xunknown2p5"
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02d.s b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02d.s
new file mode 100644
index 0000000..6ef5ee5
--- /dev/null
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-arch-failed-02d.s
@@ -0,0 +1 @@
+	.attribute arch, "rv32i4p6_m4p7_a4p8_zicsr4p9_xunknown4p0"
diff --git a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp b/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp
index 1a0c68f..2c008d4 100644
--- a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp
+++ b/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp
@@ -39,6 +39,7 @@ if [istarget "riscv*-*-*"] {
     run_dump_test "attr-merge-priv-spec-02"
     run_dump_test "attr-merge-priv-spec-03"
     run_dump_test "attr-merge-arch-failed-01"
+    run_dump_test "attr-merge-arch-failed-02"
     run_dump_test "attr-merge-stack-align-failed"
     run_dump_test "attr-merge-priv-spec-failed-01"
     run_dump_test "attr-merge-priv-spec-failed-02"
-- 
2.7.4


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/3] RISC-V: Minor cleanup and typos when merging priv spec attributes.
  2020-08-20  6:34 [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues Nelson Chu
  2020-08-20  6:34 ` [PATCH 1/3] RISC-V: Improve the error message for the mis-matched ISA versions Nelson Chu
  2020-08-20  6:34 ` [PATCH 2/3] RISC-V: Report warnings rather than errors " Nelson Chu
@ 2020-08-20  6:34 ` Nelson Chu
  2020-08-25 17:13 ` [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues Palmer Dabbelt
  3 siblings, 0 replies; 8+ messages in thread
From: Nelson Chu @ 2020-08-20  6:34 UTC (permalink / raw)
  To: binutils; +Cc: jimw, kito.cheng, nelson.chu

	bfd/
	* elfnn-riscv.c (riscv_merge_attributes): Fix comment typos.

	ld/
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Remove
	the useless `warnings` keywords.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Likewise.
---
 bfd/elfnn-riscv.c                                          | 4 ++--
 ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d | 4 ++--
 ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d | 4 ++--
 ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d | 4 ++--
 ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d | 4 ++--
 ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d | 4 ++--
 ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d | 4 ++--
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 513785e..5fc08fe 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -3046,7 +3046,7 @@ riscv_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
 		   out_attr[Tag_b].i,
 		   out_attr[Tag_c].i);
 
-		/* The priv spec v1.9.1 can be linked with other spec
+		/* The priv spec v1.9.1 can not be linked with other spec
 		   versions since the conflicts.  We plan to drop the
 		   v1.9.1 in a year or two, so this confict should be
 		   removed in the future.  */
@@ -3058,7 +3058,7 @@ riscv_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
 			 "linked with other spec versions."));
 		  }
 
-		/* Update the output priv attributes to the newest.  */
+		/* Update the output priv spec to the newest one.  */
 		if (in_priv_spec > out_priv_spec)
 		  {
 		    out_attr[Tag_a].i = in_attr[Tag_a].i;
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d
index 0d5d6dc..007eaa3 100644
--- a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d
@@ -2,8 +2,8 @@
 #source: attr-merge-priv-spec-c.s
 #as:
 #ld: -r
-#warning: .*warning: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
-#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#warning: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
+#warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
 #readelf: -A
 
 Attribute Section: riscv
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d
index f0f75b2..6707cee 100644
--- a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d
@@ -2,8 +2,8 @@
 #source: attr-merge-priv-spec-a.s
 #as:
 #ld: -r
-#warning: .*warning: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
-#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#warning: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
+#warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
 #readelf: -A
 
 Attribute Section: riscv
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d
index af51552..7679fbf 100644
--- a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d
@@ -3,8 +3,8 @@
 #source: attr-merge-priv-spec-c.s
 #as:
 #ld: -r
-#warning: .*warning: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
-#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#warning: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
+#warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
 #readelf: -A
 
 Attribute Section: riscv
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d
index 2328807..ee37ce1 100644
--- a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d
@@ -3,8 +3,8 @@
 #source: attr-merge-priv-spec-c.s
 #as:
 #ld: -r
-#warning: .*warning: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
-#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#warning: .*use privilege spec version 1.11.0 but the output use version 1.9.1.
+#warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
 #readelf: -A
 
 Attribute Section: riscv
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d
index cabaab6..c5fafad 100644
--- a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d
@@ -3,8 +3,8 @@
 #source: attr-merge-priv-spec-a.s
 #as:
 #ld: -r
-#warning: .*warning: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
-#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#warning: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
+#warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
 #readelf: -A
 
 Attribute Section: riscv
diff --git a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d
index e774748..7251be0 100644
--- a/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d
+++ b/ld/testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d
@@ -3,8 +3,8 @@
 #source: attr-merge-priv-spec-a.s
 #as:
 #ld: -r
-#warning: .*warning: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
-#warning: .*warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
+#warning: .*use privilege spec version 1.9.1 but the output use version 1.11.0.
+#warning: .*privilege spec version 1.9.1 can not be linked with other spec versions.
 #readelf: -A
 
 Attribute Section: riscv
-- 
2.7.4


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues
  2020-08-20  6:34 [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues Nelson Chu
                   ` (2 preceding siblings ...)
  2020-08-20  6:34 ` [PATCH 3/3] RISC-V: Minor cleanup and typos when merging priv spec attributes Nelson Chu
@ 2020-08-25 17:13 ` Palmer Dabbelt
  2020-08-25 17:40   ` Fangrui Song
  3 siblings, 1 reply; 8+ messages in thread
From: Palmer Dabbelt @ 2020-08-25 17:13 UTC (permalink / raw)
  To: nelson.chu; +Cc: binutils, kito.cheng

On Wed, 19 Aug 2020 23:34:39 PDT (-0700), nelson.chu@sifive.com wrote:
> Hi binutils,
>
> There are three patches used to fix some minor issues when linker merging
> ELF attributes.
>
> * The first patch from Kito cheng fixs the wrong error reports when the ISA
> versions are mis-matched.  Consider the following case,
>
> $ cat a.s
> .attribute arch, "rv64i2p0_m2p0_a2p0"
> $ cat b.s
> .attribute arch, "rv64i2p0_m2p0_a3p0"
> $ riscv64-unknown-elf-as a.s -o a.o
> $ riscv64-unknown-elf-as b.s -o b.o
> $ riscv64-unknown-elf-ld -r a.o b.o
> riscv64-unknown-elf-ld: error: b.o: Mis-matched ISA version for 'm' extension. 2.0 vs 2.0
> riscv64-unknown-elf-ld: failed to merge target specific data of file b.o
>
> But the mis-matched ISA should be 'a' rather than 'm'.  This patch will fix
> the wrong message.
>
> $ riscv64-unknown-elf-ld-new -r a.o b.o
> riscv64-unknown-elf-ld: error: b.o: Mis-matched ISA version for 'a' extension. 3.0 vs 2.0
>
> * The second patch allows to link objects with different versions of ISA.
> The different ISA versions should be compatible, unless there are some known
> conflicts.  Same as what the privileged spec attributes did, report warnings
> for those different ISA versions are merged should be enough.  So the above
> mis-matched errors will be changed to warnings,
>
> $ riscv64-unknown-elf-ld-new -r a.o b.o
> riscv64-unknown-elf-ld: warning: b.o: Mis-matched ISA version 3.0 for 'a' extension, the output version is 2.0.
>
> * And the third patch just fixs typos amd do some minor cleanups when merging priv spec attributes.
>
> Thanks
> Nelson

These LGTM.  Thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues
  2020-08-25 17:13 ` [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues Palmer Dabbelt
@ 2020-08-25 17:40   ` Fangrui Song
  2020-08-26  1:29     ` Nelson Chu
  0 siblings, 1 reply; 8+ messages in thread
From: Fangrui Song @ 2020-08-25 17:40 UTC (permalink / raw)
  To: nelson.chu; +Cc: kito.cheng, binutils, Palmer Dabbelt

On 2020-08-25, Palmer Dabbelt wrote:
>On Wed, 19 Aug 2020 23:34:39 PDT (-0700), nelson.chu@sifive.com wrote:
>>Hi binutils,
>>
>>There are three patches used to fix some minor issues when linker merging
>>ELF attributes.
>>
>>* The first patch from Kito cheng fixs the wrong error reports when the ISA
>>versions are mis-matched.  Consider the following case,
>>
>>$ cat a.s
>>.attribute arch, "rv64i2p0_m2p0_a2p0"
>>$ cat b.s
>>.attribute arch, "rv64i2p0_m2p0_a3p0"
>>$ riscv64-unknown-elf-as a.s -o a.o
>>$ riscv64-unknown-elf-as b.s -o b.o
>>$ riscv64-unknown-elf-ld -r a.o b.o
>>riscv64-unknown-elf-ld: error: b.o: Mis-matched ISA version for 'm' extension. 2.0 vs 2.0
>>riscv64-unknown-elf-ld: failed to merge target specific data of file b.o
>>
>>But the mis-matched ISA should be 'a' rather than 'm'.  This patch will fix
>>the wrong message.
>>
>>$ riscv64-unknown-elf-ld-new -r a.o b.o
>>riscv64-unknown-elf-ld: error: b.o: Mis-matched ISA version for 'a' extension. 3.0 vs 2.0
>>
>>* The second patch allows to link objects with different versions of ISA.
>>The different ISA versions should be compatible, unless there are some known
>>conflicts.  Same as what the privileged spec attributes did, report warnings
>>for those different ISA versions are merged should be enough.  So the above
>>mis-matched errors will be changed to warnings,
>>
>>$ riscv64-unknown-elf-ld-new -r a.o b.o
>>riscv64-unknown-elf-ld: warning: b.o: Mis-matched ISA version 3.0 for 'a' extension, the output version is 2.0.
>>
>>* And the third patch just fixs typos amd do some minor cleanups when merging priv spec attributes.
>>
>>Thanks
>>Nelson
>
>These LGTM.  Thanks!

One minor lit. Most diagnostics are un-capitalized and do not have a
full stop.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] Allow to link objects with different versions of ISA,  and fix some minor issues
  2020-08-25 17:40   ` Fangrui Song
@ 2020-08-26  1:29     ` Nelson Chu
  2020-09-03  3:29       ` Nelson Chu
  0 siblings, 1 reply; 8+ messages in thread
From: Nelson Chu @ 2020-08-26  1:29 UTC (permalink / raw)
  To: Palmer Dabbelt, Fangrui Song; +Cc: Kito Cheng, Binutils

Thanks for all your help.  I plan to wait a week or two in case
everyone is okay with these patches.  Any suggestions and ideas are
welcome.

On Wed, Aug 26, 2020 at 1:40 AM Fangrui Song <i@maskray.me> wrote:
> One minor lit. Most diagnostics are un-capitalized and do not have a
> full stop.

Thanks for the information, I will fix them in these patches.  As for
other diagnostics, I should improve them in the future patches.


Thanks
Nelson

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] Allow to link objects with different versions of ISA,  and fix some minor issues
  2020-08-26  1:29     ` Nelson Chu
@ 2020-09-03  3:29       ` Nelson Chu
  0 siblings, 0 replies; 8+ messages in thread
From: Nelson Chu @ 2020-09-03  3:29 UTC (permalink / raw)
  To: Palmer Dabbelt, Fangrui Song; +Cc: Kito Cheng, Binutils

The series of patches are already committed.  Also fix the diagnostics
issue for them.

Thanks
Nelson

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-09-03  3:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-20  6:34 [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues Nelson Chu
2020-08-20  6:34 ` [PATCH 1/3] RISC-V: Improve the error message for the mis-matched ISA versions Nelson Chu
2020-08-20  6:34 ` [PATCH 2/3] RISC-V: Report warnings rather than errors " Nelson Chu
2020-08-20  6:34 ` [PATCH 3/3] RISC-V: Minor cleanup and typos when merging priv spec attributes Nelson Chu
2020-08-25 17:13 ` [PATCH 0/3] Allow to link objects with different versions of ISA, and fix some minor issues Palmer Dabbelt
2020-08-25 17:40   ` Fangrui Song
2020-08-26  1:29     ` Nelson Chu
2020-09-03  3:29       ` Nelson Chu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).