RISC-V: Allow nested implications for extensions
authorNathan Huckleberry <nhuck@google.com>
Fri, 30 Jun 2023 20:44:17 +0000 (22:44 +0200)
committerJeff Law <jlaw@ventanamicro>
Sat, 1 Jul 2023 13:29:34 +0000 (07:29 -0600)
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.

bfd/ChangeLog:

* elfxx-riscv.c (riscv_parse_add_implicit_subsets): Allow nested
implications for extensions.

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
bfd/elfxx-riscv.c

index 426139d4960cf4a8fcf15cb4678ece9928a574c8..f7fb7d88d76a31e932ee56df33dee4caa797e88b 100644 (file)
@@ -1873,14 +1873,29 @@ 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)
     {
-      riscv_subset_t *subset = NULL;
-      if (riscv_lookup_subset (rps->subset_list, t->subset_name, &subset)
-         && t->check_func (t->implicit_name, subset))
-       riscv_parse_add_subset (rps, t->implicit_name,
-                               RISCV_UNKNOWN_VERSION,
-                               RISCV_UNKNOWN_VERSION, true);
+      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)
+             && !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;
+           }
+       }
     }
 }