public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [committed] RISC-V: Allow to link the objects with unknown prefixed extensions.
@ 2021-05-26  3:05 Nelson Chu
  0 siblings, 0 replies; only message in thread
From: Nelson Chu @ 2021-05-26  3:05 UTC (permalink / raw)
  To: binutils, jimw, kito.cheng

Since the policies of GNU and llvm toolchain are different for now,
current binutils mainline cannot accept any draft extensions, including
rvv, zfh, ....  The Clang/LLVM allows these draft stuff on mainline,
but the GNU ld might be used with them, so this causes the link time
problems.

The patch allows ld to link the objects with unknown prefixed extensions,
which are probably generated by LLVM or customized toolchains.

bfd/
    * elfxx-riscv.h (check_unknown_prefixed_ext): New bool.
    * elfxx-riscv.c (riscv_parse_prefixed_ext): Do not check the
    prefixed extension name if check_unknown_prefixed_ext is false.
    * elfnn-riscv.c (riscv_merge_arch_attr_info): Set
    check_unknown_prefixed_ext to false for linker.
gas/
    * config/tc-riscv.c (riscv_set_arch): Set
    check_unknown_prefixed_ext to true for assembler.
---
 bfd/ChangeLog         | 8 ++++++++
 bfd/elfnn-riscv.c     | 2 ++
 bfd/elfxx-riscv.c     | 3 ++-
 bfd/elfxx-riscv.h     | 1 +
 gas/ChangeLog         | 5 +++++
 gas/config/tc-riscv.c | 1 +
 6 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index fec2dcb..608ea54 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2021-05-26  Nelson Chu  <nelson.chu@sifive.com>
+
+	* elfxx-riscv.h (check_unknown_prefixed_ext): New bool.
+	* elfxx-riscv.c (riscv_parse_prefixed_ext): Do not check the
+	prefixed extension name if check_unknown_prefixed_ext is false.
+	* elfnn-riscv.c (riscv_merge_arch_attr_info): Set
+	check_unknown_prefixed_ext to false for linker.
+
 2021-05-25  Nick Clifton  <nickc@redhat.com>
 
 	* elf32-arn.c (struct elf_arm_obj_tdata): Add num_entries field.
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 2068ede..d2781f3 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -3558,11 +3558,13 @@ riscv_merge_arch_attr_info (bfd *ibfd, char *in_arch, char *out_arch)
   rpe_in.error_handler = _bfd_error_handler;
   rpe_in.xlen = &xlen_in;
   rpe_in.get_default_version = NULL;
+  rpe_in.check_unknown_prefixed_ext = false;
 
   rpe_out.subset_list = &out_subsets;
   rpe_out.error_handler = _bfd_error_handler;
   rpe_out.xlen = &xlen_out;
   rpe_out.get_default_version = NULL;
+  rpe_out.check_unknown_prefixed_ext = false;
 
   if (in_arch == NULL && out_arch == NULL)
     return NULL;
diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 7206ec8..39b69e2 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1681,7 +1681,8 @@ riscv_parse_prefixed_ext (riscv_parse_subset_t *rps,
 	 and cannot simply be the prefixed name.  */
 
       /* Check that the extension name is well-formed.  */
-      if (!riscv_valid_prefixed_ext (subset))
+      if (rps->check_unknown_prefixed_ext
+	  && !riscv_valid_prefixed_ext (subset))
 	{
 	  rps->error_handler
 	    (_("-march=%s: unknown prefixed ISA extension `%s'"),
diff --git a/bfd/elfxx-riscv.h b/bfd/elfxx-riscv.h
index ff18ff6..c2fff92 100644
--- a/bfd/elfxx-riscv.h
+++ b/bfd/elfxx-riscv.h
@@ -74,6 +74,7 @@ typedef struct
   void (*get_default_version) (const char *,
 			       int *,
 			       int *);
+  bool check_unknown_prefixed_ext;
 } riscv_parse_subset_t;
 
 extern bool
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 45cce1b..eac946f 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2021-05-26  Nelson Chu  <nelson.chu@sifive.com>
+
+	* config/tc-riscv.c (riscv_set_arch): Set
+	check_unknown_prefixed_ext to true for assembler.
+
 2021-05-25  Tamar Christina  <tamar.christina@arm.com>
 
 	PR gas/25235
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index a76e53d..42e5752 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -410,6 +410,7 @@ riscv_set_arch (const char *s)
   rps.error_handler = as_bad;
   rps.xlen = &xlen;
   rps.get_default_version = riscv_get_default_ext_version;
+  rps.check_unknown_prefixed_ext = true;
 
   if (s == NULL)
     return;
-- 
2.7.4


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-26  3:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26  3:05 [committed] RISC-V: Allow to link the objects with unknown prefixed extensions 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).