This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2 1/2] [ARC] Fix handling of cpu=... disassembler option value

Changes in V2:

* Use disassembler_options_cmp to compare string instead of using strtok, which
  required string duplication.
* Add a second patch that introduces usage of FOR_EACH_DISASSEMBLER_OPTION to


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 is fixed by using disassembler_options_cmp function, which compares string
treating `,' the same way as `\0'.

This function also solves a problem with option order in parse_option.
Previously, if several option had same prefix (e.g. fpud, fpuda), then the
longer one should have been compared first, otherwise when longer option is
passed it would be treated as a short one, because

  CONST_STRNEQ ("fpud", "fpuda")

would be true.  The order of options was correct for ARC, so there were no
bugs per se, but with disassembler_option_cmp there is no risk of such a bug
being introduced in the future.


yyyy-mm-dd  Anton Kolesov  <>

	* arc-dis.c (parse_option): Use disassembler_options_cmp to compare
	  disassembler option strings.
	  (parse_cpu_option): Likewise.
 opcodes/arc-dis.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c
index edd0c07..dc9f5d7 100644
--- a/opcodes/arc-dis.c
+++ b/opcodes/arc-dis.c
@@ -740,16 +740,16 @@ operand_iterator_next (struct arc_operand_iterator *iter,
 static void
 parse_option (const char *option)
-  if (CONST_STRNEQ (option, "dsp"))
+  if (!disassembler_options_cmp (option, "dsp"))
     add_to_decodelist (DSP, NONE);
-  else if (CONST_STRNEQ (option, "spfp"))
+  else if (!disassembler_options_cmp (option, "spfp"))
     add_to_decodelist (FLOAT, SPX);
-  else if (CONST_STRNEQ (option, "dpfp"))
+  else if (!disassembler_options_cmp (option, "dpfp"))
     add_to_decodelist (FLOAT, DPX);
-  else if (CONST_STRNEQ (option, "quarkse_em"))
+  else if (!disassembler_options_cmp (option, "quarkse_em"))
       add_to_decodelist (FLOAT, DPX);
       add_to_decodelist (FLOAT, SPX);
@@ -757,16 +757,16 @@ parse_option (const char *option)
       add_to_decodelist (FLOAT, QUARKSE2);
-  else if (CONST_STRNEQ (option, "fpuda"))
+  else if (!disassembler_options_cmp (option, "fpuda"))
     add_to_decodelist (FLOAT, DPA);
-  else if (CONST_STRNEQ (option, "fpus"))
+  else if (!disassembler_options_cmp (option, "fpus"))
       add_to_decodelist (FLOAT, SP);
       add_to_decodelist (FLOAT, CVT);
-  else if (CONST_STRNEQ (option, "fpud"))
+  else if (!disassembler_options_cmp (option, "fpud"))
       add_to_decodelist (FLOAT, DP);
       add_to_decodelist (FLOAT, CVT);
@@ -808,7 +808,7 @@ parse_cpu_option (const char *option)
   for (i = 0; cpu_types[i].name; ++i)
-      if (!strcasecmp (cpu_types[i].name, option))
+      if (!disassembler_options_cmp (cpu_types[i].name, option))
 	  return cpu_types[i].flags;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]