public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Nelson Chu <nelsonc1225@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] RISC-V: Make riscv_is_mapping_symbol stricter
Date: Fri,  1 Dec 2023 03:26:15 +0000 (GMT)	[thread overview]
Message-ID: <20231201032615.4A6303858D38@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2b33b0d960076b1186bcc454a9627a5451dca17a

commit 2b33b0d960076b1186bcc454a9627a5451dca17a
Author: Patrick O'Neill <patrick@rivosinc.com>
Date:   Thu Nov 30 18:47:39 2023 -0800

    RISC-V: Make riscv_is_mapping_symbol stricter
    
    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>

Diff:
---
 bfd/cpu-riscv.c     | 5 +++--
 opcodes/riscv-dis.c | 4 +---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/bfd/cpu-riscv.c b/bfd/cpu-riscv.c
index a478797da69..5ec766d3375 100644
--- a/bfd/cpu-riscv.c
+++ b/bfd/cpu-riscv.c
@@ -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));
 }
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index cb521dc8174..68674380797 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -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

                 reply	other threads:[~2023-12-01  3:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231201032615.4A6303858D38@sourceware.org \
    --to=nelsonc1225@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).