This is the mail archive of the binutils@sourceware.org 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]

RE: [PATCH] [ARC] Fix handling of cpu=... disassembler option value


Hi Pedro,

> On 06/15/2017 03:59 PM, Anton Kolesov wrote:
> > 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.
>
> Couldn't this use disassembler_options_cmp /
> FOR_EACH_DISASSEMBLER_OPTION?
> See e.g. ppc-dis.c:ppc_parse_cpu for example.

FOR_EACH_DISASSEMBLER_OPTION advances pointer to the beginning of next option,
but it doesn't create a new string with \0 at the end. So, for example, this
code:

  const char* option;
  FOR_EACH_DISASSEMBLER_OPTION (option, "fpuda,fpud,fpus")
    {
      printf ("option: %s\n", option);
    }

will print:

  option: fpuda,fpud,fpus
  option: fpud,fpus
  option: fpus

As a result this macro can be used to improve existing code in arc-dis.c,
however it doesn't address the issue that this particular patch is trying to
fix. I can make a separate patch that would change ARC code to use
FOR_EACH_DISASSEMBLER_OPTION.

Anton


>
> Thanks,
> Pedro Alves


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