[PATCH 09/14] Allow nested implications for extensions.

Nathan Huckleberry nhuck@google.com
Thu Jun 29 17:18:34 GMT 2023


Certain extensions require two levels of implications.  For example,
zvkng implies zvkn and zvkn implies zvkned.  Enabling zvkng should also
enable zvkned.

This patch fixes this behavior.

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
---
 bfd/elfxx-riscv.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 890e10d1812..8bb77db5528 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1870,15 +1870,27 @@ static void
 riscv_parse_add_implicit_subsets (riscv_parse_subset_t *rps)
 {
   struct riscv_implicit_subset *t = riscv_implicit_subsets;
-  for (; t->subset_name; t++)
+  bool finished = false;
+  while (!finished) {
+    finished = true;
+    for (; t->subset_name; t++)
     {
       riscv_subset_t *subset = NULL;
+      riscv_subset_t *implicit_subset = NULL;
       if (riscv_lookup_subset (rps->subset_list, t->subset_name, &subset)
-	  && t->check_func (t->implicit_name, subset))
+	  && !riscv_lookup_subset (rps->subset_list, t->implicit_name, &implicit_subset)
+	  && t->check_func (t->implicit_name, subset)) {
 	riscv_parse_add_subset (rps, t->implicit_name,
 				RISCV_UNKNOWN_VERSION,
 				RISCV_UNKNOWN_VERSION, true);
+
+	// Restart the loop and pick up any new implications.
+	finished = false;
+	t = riscv_implicit_subsets;
+	break;
+      }
     }
+  }
 }
 
 /* Check extensions conflicts.  */
-- 
2.41.0.255.g8b1d071c50-goog



More information about the Binutils mailing list