public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] RISC-V: Add support for numbered ISA mapping strings
@ 2023-09-27 12:42 Joseph Faulls
  2023-09-28  1:41 ` Nelson Chu
  0 siblings, 1 reply; 4+ messages in thread
From: Joseph Faulls @ 2023-09-27 12:42 UTC (permalink / raw)
  To: binutils; +Cc: jbeulich, nelson

[-- Attachment #1: Type: text/plain, Size: 1382 bytes --]

The elf psabi allows for mapping symbols to be of the form $x<ISA>.<any>

    opcodes/
            * riscv-dis.c (riscv_get_map_state): allow mapping symbol to
              be suffixed by a unique identifier .<any>

Changes from v1:

  *   Use xmalloc (thanks Jan)
---
opcodes/riscv-dis.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index c0fd0625a2d..18a5c26f9a6 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -869,7 +869,23 @@ riscv_get_map_state (int n,
     {
       *state = MAP_INSN;
       riscv_release_subset_list (&riscv_subsets);
-      riscv_parse_subset (&riscv_rps_dis, name + 2);
+
+      /* ISA mapping string may be numbered, suffixed with '.n'. Do not
+        consider this as part of the ISA string.  */
+      char *suffix = strchr (name, '.');
+      if (suffix)
+       {
+         int suffix_index = (int)(suffix - name);
+         char *name_substr = xmalloc (suffix_index + 1);
+         strncpy (name_substr, name, suffix_index);
+         name_substr[suffix_index] = '\0';
+         riscv_parse_subset (&riscv_rps_dis, name_substr + 2);
+         free (name_substr);
+       }
+      else
+       {
+         riscv_parse_subset (&riscv_rps_dis, name + 2);
+       }
     }
   else
     return false;
--
2.34.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] RISC-V: Add support for numbered ISA mapping strings
  2023-09-27 12:42 [PATCH v2] RISC-V: Add support for numbered ISA mapping strings Joseph Faulls
@ 2023-09-28  1:41 ` Nelson Chu
  2023-10-12 15:46   ` [EXTERNAL] " Joseph Faulls
  0 siblings, 1 reply; 4+ messages in thread
From: Nelson Chu @ 2023-09-28  1:41 UTC (permalink / raw)
  To: Joseph Faulls; +Cc: binutils, jbeulich

[-- Attachment #1: Type: text/plain, Size: 1838 bytes --]

Okay, although the current GNU assembler won't generate numbered
architecture strings, other tools may generate, so this looks reasonable.

Thanks
Nelson

On Wed, Sep 27, 2023 at 8:42 PM Joseph Faulls <Joseph.Faulls@imgtec.com>
wrote:

> The elf psabi allows for mapping symbols to be of the form $x<ISA>.<any>
>
>
>
>     opcodes/
>
>             * riscv-dis.c (riscv_get_map_state): allow mapping symbol to
>
>               be suffixed by a unique identifier .<any>
>
>
>
> Changes from v1:
>
>    - Use xmalloc (thanks Jan)
>
> ---
>
> opcodes/riscv-dis.c | 18 +++++++++++++++++-
>
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
>
>
> diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
>
> index c0fd0625a2d..18a5c26f9a6 100644
>
> --- a/opcodes/riscv-dis.c
>
> +++ b/opcodes/riscv-dis.c
>
> @@ -869,7 +869,23 @@ riscv_get_map_state (int n,
>
>      {
>
>        *state = MAP_INSN;
>
>        riscv_release_subset_list (&riscv_subsets);
>
> -      riscv_parse_subset (&riscv_rps_dis, name + 2);
>
> +
>
> +      /* ISA mapping string may be numbered, suffixed with '.n'. Do not
>
> +        consider this as part of the ISA string.  */
>
> +      char *suffix = strchr (name, '.');
>
> +      if (suffix)
>
> +       {
>
> +         int suffix_index = (int)(suffix - name);
>
> +         char *name_substr = xmalloc (suffix_index + 1);
>
> +         strncpy (name_substr, name, suffix_index);
>
> +         name_substr[suffix_index] = '\0';
>
> +         riscv_parse_subset (&riscv_rps_dis, name_substr + 2);
>
> +         free (name_substr);
>
> +       }
>
> +      else
>
> +       {
>
> +         riscv_parse_subset (&riscv_rps_dis, name + 2);
>
> +       }
>
>      }
>
>    else
>
>      return false;
>
> --
>
> 2.34.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [EXTERNAL] Re: [PATCH v2] RISC-V: Add support for numbered ISA mapping strings
  2023-09-28  1:41 ` Nelson Chu
@ 2023-10-12 15:46   ` Joseph Faulls
  2023-10-13  1:57     ` Nelson Chu
  0 siblings, 1 reply; 4+ messages in thread
From: Joseph Faulls @ 2023-10-12 15:46 UTC (permalink / raw)
  To: Nelson Chu; +Cc: binutils, jbeulich

[-- Attachment #1: Type: text/plain, Size: 1999 bytes --]

Ping

If this looks good, could someone commit it?

Thanks,
Joe

From: Nelson Chu <nelson@rivosinc.com>
Sent: Thursday, September 28, 2023 2:41 AM
To: Joseph Faulls <Joseph.Faulls@imgtec.com>
Cc: binutils@sourceware.org; jbeulich@suse.com
Subject: [EXTERNAL] Re: [PATCH v2] RISC-V: Add support for numbered ISA mapping strings

Okay, although the current GNU assembler won't generate numbered architecture strings, other tools may generate, so this looks reasonable.

Thanks
Nelson

On Wed, Sep 27, 2023 at 8:42 PM Joseph Faulls <Joseph.Faulls@imgtec.com<mailto:Joseph.Faulls@imgtec.com>> wrote:
The elf psabi allows for mapping symbols to be of the form $x<ISA>.<any>

    opcodes/
            * riscv-dis.c (riscv_get_map_state): allow mapping symbol to
              be suffixed by a unique identifier .<any>

Changes from v1:

  *   Use xmalloc (thanks Jan)
---
opcodes/riscv-dis.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index c0fd0625a2d..18a5c26f9a6 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -869,7 +869,23 @@ riscv_get_map_state (int n,
     {
       *state = MAP_INSN;
       riscv_release_subset_list (&riscv_subsets);
-      riscv_parse_subset (&riscv_rps_dis, name + 2);
+
+      /* ISA mapping string may be numbered, suffixed with '.n'. Do not
+        consider this as part of the ISA string.  */
+      char *suffix = strchr (name, '.');
+      if (suffix)
+       {
+         int suffix_index = (int)(suffix - name);
+         char *name_substr = xmalloc (suffix_index + 1);
+         strncpy (name_substr, name, suffix_index);
+         name_substr[suffix_index] = '\0';
+         riscv_parse_subset (&riscv_rps_dis, name_substr + 2);
+         free (name_substr);
+       }
+      else
+       {
+         riscv_parse_subset (&riscv_rps_dis, name + 2);
+       }
     }
   else
     return false;
--
2.34.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [EXTERNAL] Re: [PATCH v2] RISC-V: Add support for numbered ISA mapping strings
  2023-10-12 15:46   ` [EXTERNAL] " Joseph Faulls
@ 2023-10-13  1:57     ` Nelson Chu
  0 siblings, 0 replies; 4+ messages in thread
From: Nelson Chu @ 2023-10-13  1:57 UTC (permalink / raw)
  To: Joseph Faulls; +Cc: binutils, jbeulich

[-- Attachment #1: Type: text/plain, Size: 2396 bytes --]

Committed with indents fixing.

Nelson

On Thu, Oct 12, 2023 at 11:46 PM Joseph Faulls <Joseph.Faulls@imgtec.com>
wrote:

> Ping
>
>
>
> If this looks good, could someone commit it?
>
>
>
> Thanks,
> Joe
>
>
>
> *From:* Nelson Chu <nelson@rivosinc.com>
> *Sent:* Thursday, September 28, 2023 2:41 AM
> *To:* Joseph Faulls <Joseph.Faulls@imgtec.com>
> *Cc:* binutils@sourceware.org; jbeulich@suse.com
> *Subject:* [EXTERNAL] Re: [PATCH v2] RISC-V: Add support for numbered ISA
> mapping strings
>
> Okay, although the current GNU assembler won't generate numbered
> architecture strings, other tools may generate, so this looks reasonable.
>
>
>
> Thanks
>
> Nelson
>
>
>
> On Wed, Sep 27, 2023 at 8:42 PM Joseph Faulls <Joseph.Faulls@imgtec.com>
> wrote:
>
> The elf psabi allows for mapping symbols to be of the form $x<ISA>.<any>
>
>
>
>     opcodes/
>
>             * riscv-dis.c (riscv_get_map_state): allow mapping symbol to
>
>               be suffixed by a unique identifier .<any>
>
>
>
> Changes from v1:
>
>    - Use xmalloc (thanks Jan)
>
> ---
>
> opcodes/riscv-dis.c | 18 +++++++++++++++++-
>
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
>
>
> diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
>
> index c0fd0625a2d..18a5c26f9a6 100644
>
> --- a/opcodes/riscv-dis.c
>
> +++ b/opcodes/riscv-dis.c
>
> @@ -869,7 +869,23 @@ riscv_get_map_state (int n,
>
>      {
>
>        *state = MAP_INSN;
>
>        riscv_release_subset_list (&riscv_subsets);
>
> -      riscv_parse_subset (&riscv_rps_dis, name + 2);
>
> +
>
> +      /* ISA mapping string may be numbered, suffixed with '.n'. Do not
>
> +        consider this as part of the ISA string.  */
>
> +      char *suffix = strchr (name, '.');
>
> +      if (suffix)
>
> +       {
>
> +         int suffix_index = (int)(suffix - name);
>
> +         char *name_substr = xmalloc (suffix_index + 1);
>
> +         strncpy (name_substr, name, suffix_index);
>
> +         name_substr[suffix_index] = '\0';
>
> +         riscv_parse_subset (&riscv_rps_dis, name_substr + 2);
>
> +         free (name_substr);
>
> +       }
>
> +      else
>
> +       {
>
> +         riscv_parse_subset (&riscv_rps_dis, name + 2);
>
> +       }
>
>      }
>
>    else
>
>      return false;
>
> --
>
> 2.34.1
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-13  1:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27 12:42 [PATCH v2] RISC-V: Add support for numbered ISA mapping strings Joseph Faulls
2023-09-28  1:41 ` Nelson Chu
2023-10-12 15:46   ` [EXTERNAL] " Joseph Faulls
2023-10-13  1:57     ` Nelson Chu

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).