RISC-V: Add support for numbered ISA mapping strings
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_binutils_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_binutils_check--master-arm |
success
|
Testing passed
|
Commit Message
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>
---
opcodes/riscv-dis.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
--
2.34.1
Comments
On 27.09.2023 13:20, Joseph Faulls wrote:
> --- 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 = malloc (suffix_index + 1);
> + strncpy (name_substr, name, suffix_index);
You want to either use xmalloc(), or you need to check for getting
back NULL here.
Jan
> + 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
@@ -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 = malloc (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;