]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
RISC-V: Make riscv_is_mapping_symbol stricter
authorPatrick O'Neill <patrick@rivosinc.com>
Fri, 1 Dec 2023 02:47:39 +0000 (18:47 -0800)
committerNelson Chu <nelson@rivosinc.com>
Fri, 1 Dec 2023 03:22:45 +0000 (11:22 +0800)
riscv_is_mapping_symbol currently accepts any symbol that starts with $x
or $d. This patch makes the check more strict, requiring exactly $x, $d,
or $xrv. It also makes use of this stricter mapping in
riscv_is_valid_mapping_symbol.

ChangeLog:

* bfd/cpu-riscv.c (riscv_elf_is_mapping_symbols): Match only
strings that are exactly $x, $d, or $xrv.
* opcodes/riscv-dis.c (riscv_is_valid_mapping_symbol): Use
riscv_elf_is_mapping_symbols.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
bfd/cpu-riscv.c
opcodes/riscv-dis.c

index a478797da69cd3c0796d75a6e46e779e49c17b5e..5ec766d337500c2c368ae5a7059eb197b75403f8 100644 (file)
@@ -147,6 +147,7 @@ riscv_get_priv_spec_class_from_numbers (unsigned int major,
 bool
 riscv_elf_is_mapping_symbols (const char *name)
 {
-  return (!strncmp (name, "$d", 2)
-         || !strncmp (name, "$x", 2));
+  return (!strcmp (name, "$d")
+         || !strcmp (name, "$x")
+         || !strncmp (name, "$xrv", 4));
 }
index cb521dc817457e43687d81de453bb9badd0f9eb2..686743807975a494d90b5efbb52e126cf1d6a114 100644 (file)
@@ -957,9 +957,7 @@ riscv_is_valid_mapping_symbol (int n,
     return false;
 
   name = bfd_asymbol_name(info->symtab[n]);
-  return (strcmp (name, "$x") == 0
-         || strcmp (name, "$d") == 0
-         || strncmp (name, "$xrv", 4) == 0);
+  return riscv_elf_is_mapping_symbols (name);
 }
 
 /* Check the sorted symbol table (sorted by the symbol value), find the