[PATCH v3 2/6] x86: don't abort() upon DATA16 prefix on (E)VEX encoded insn

H.J. Lu hjl.tools@gmail.com
Mon Jul 30 13:37:00 GMT 2018


On Mon, Jul 30, 2018 at 1:42 AM, Jan Beulich <JBeulich@suse.com> wrote:
> Instead of hitting the abort() in output_insn() (commented by "There
> should be no other prefixes for instructions with VEX prefix"), report
> a proper diagnostic instead, just like we do e.g. for invalid REP
> prefixes.
>
> gas/
> 2018-07-30  Jan Beulich  <jbeulich@suse.com>
>
>         * config/tc-i386.c (is_any_vex_encoding): New.
>         (process_immext, process_suffix): Use it.
>         (md_assemble): Likewise. Reject DATA_PREFIX with VEX/XOP/EVEX
>         insn.
>         * testsuite/gas/i386/prefix32.s, testsuite/gas/i386/prefix32.l,
>         testsuite/gas/i386/prefix64.s, testsuite/gas/i386/prefix64.l
>          New.
>         * testsuite/gas/i386/i386.exp: Run new tests.
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -3478,6 +3478,13 @@ is_evex_encoding (const insn_template *t
>          || t->opcode_modifier.staticrounding || t->opcode_modifier.sae;
>  }
>
> +static INLINE bfd_boolean
> +is_any_vex_encoding (const insn_template *t)
> +{
> +  return t->opcode_modifier.vex || t->opcode_modifier.vexopcode
> +        || is_evex_encoding (t);
> +}
> +
>  /* Build the EVEX prefix.  */
>
>  static void
> @@ -3760,9 +3767,7 @@ bad_register_operand:
>
>    gas_assert (i.imm_operands <= 1
>               && (i.operands <= 2
> -                 || ((i.tm.opcode_modifier.vex
> -                      || i.tm.opcode_modifier.vexopcode
> -                      || is_evex_encoding (&i.tm))
> +                 || (is_any_vex_encoding (&i.tm)
>                       && i.operands <= 4)));
>
>    exp = &im_expressions[i.imm_operands++];
> @@ -4125,6 +4130,13 @@ md_assemble (char *line)
>        return;
>      }
>
> +  /* Check for data size prefix on VEX/XOP/EVEX encoded insns.  */
> +  if (i.prefix[DATA_PREFIX] && is_any_vex_encoding (&i.tm))
> +    {
> +      as_bad (_("data size prefix invalid with `%s'"), i.tm.name);
> +      return;
> +    }
> +
>    /* Check if HLE prefix is OK.  */
>    if (i.hle_prefix && !check_hle ())
>      return;
> @@ -4211,8 +4223,7 @@ md_assemble (char *line)
>        as_warn (_("translating to `%sp'"), i.tm.name);
>      }
>
> -  if (i.tm.opcode_modifier.vex || i.tm.opcode_modifier.vexopcode
> -      || is_evex_encoding (&i.tm))
> +  if (is_any_vex_encoding (&i.tm))
>      {
>        if (flag_code == CODE_16BIT)
>         {
> @@ -6137,6 +6148,9 @@ process_suffix (void)
>        else if (i.suffix != QWORD_MNEM_SUFFIX
>                && !i.tm.opcode_modifier.ignoresize
>                && !i.tm.opcode_modifier.floatmf
> +              && !i.tm.opcode_modifier.vex
> +              && !i.tm.opcode_modifier.vexopcode
> +              && !is_evex_encoding (&i.tm)
>                && ((i.suffix == LONG_MNEM_SUFFIX) == (flag_code == CODE_16BIT)
>                    || (flag_code == CODE_64BIT
>                        && i.tm.opcode_modifier.jumpbyte)))

OK.

Thanks.

-- 
H.J.



More information about the Binutils mailing list