[03/11] RISC-V: Make mapping symbol checking consistent

Message ID 6c6c644515c6bc2751062543097eb14ee98e97c8.1668487922.git.research_trasio@irq.a4lg.com
State Accepted
Headers
Series RISC-V: Requirements for disassembler optimizations batch 1 |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

Tsukasa OI Nov. 15, 2022, 4:52 a.m. UTC
  There were two places where the mapping symbols are checked but had
different conditions.

-    riscv_get_map_state:          "$d" or starts with "$x"
-    riscv_elf_is_mapping_symbols: Starts with either "$x" or "$d"

Considering recent mapping symbol proposal, it's better to make symbol
checking consistent (whether the symbol _starts_ with "$[xd]").

It only checks prefix "$xrv" (mapping symbol with ISA string) only when the
prefix "$x" is matched.

opcodes/ChangeLog:

	* riscv-dis.c (riscv_get_map_state): Change the condition for
	consistency.
---
 opcodes/riscv-dis.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
  

Patch

diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index ea45a631a25..d3bd4ceec1e 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -832,16 +832,17 @@  riscv_get_map_state (int n,
     return false;
 
   name = bfd_asymbol_name(info->symtab[n]);
-  if (strcmp (name, "$x") == 0)
-    *state = MAP_INSN;
-  else if (strcmp (name, "$d") == 0)
-    *state = MAP_DATA;
-  else if (strncmp (name, "$xrv", 4) == 0)
+  if (startswith (name, "$x"))
     {
+      if (startswith (name + 2, "rv"))
+	{
+	  riscv_release_subset_list (&riscv_subsets);
+	  riscv_parse_subset (&riscv_rps_dis, name + 2);
+	}
       *state = MAP_INSN;
-      riscv_release_subset_list (&riscv_subsets);
-      riscv_parse_subset (&riscv_rps_dis, name + 2);
     }
+  else if (startswith (name, "$d"))
+    *state = MAP_DATA;
   else
     return false;