[PATCH] [ARC] Fix handling of cpu=... disassembler option value
Anton Kolesov
Anton.Kolesov@synopsys.com
Thu Jun 15 14:59:00 GMT 2017
There is a bug in handling of cpu=... disassembler option in case there are
other options after it, for example, `cpu=EM,dsp'. In this case `EM,dsp' is
treated as an option value, and strcasecmp reports is as non-equal to "EM".
This could have been fixed by using strncasecmp and passing length of
cpu_types[i].name as size argument, or using strcasestr, but that would cause
another problem as value `em4,dsp' would be equal to `em' cpy_type.name in
those cases. Therefore the right solution is to extract value of cpu option
fully and pass it as an argument to parse_cpu_option.
opcodes/ChangeLog:
yyyy-mm-dd Anton Kolesov <Anton.Kolesov@synopsys.com>
* arc-dis.c (parse_disassembler_options): Properly handle cpu=...
option when there is an option after it.
---
opcodes/arc-dis.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c
index edd0c07..0121682 100644
--- a/opcodes/arc-dis.c
+++ b/opcodes/arc-dis.c
@@ -844,8 +844,12 @@ parse_disassembler_options (const char *options)
/* A CPU option? Cannot use STRING_COMMA_LEN because strncmp is also a
preprocessor macro. */
if (strncmp (options, "cpu=", 4) == 0)
- /* Strip leading `cpu=`. */
- enforced_isa_mask = parse_cpu_option (options + 4);
+ {
+ /* Strip leading `cpu=`. */
+ char *options_copy = strdup (options + 4);
+ enforced_isa_mask = parse_cpu_option (strtok (options_copy, ","));
+ free (options_copy);
+ }
else
parse_option (options);
--
2.8.3
More information about the Binutils
mailing list