[PATCH] X86: Disassemble primary opcode map's group 2 ModRM.reg == 6 aliases correctly

H.J. Lu hjl.tools@gmail.com
Sun May 28 16:38:00 GMT 2017


On Sun, May 28, 2017 at 1:57 AM, Borislav Petkov <bp@suse.de> wrote:
> On Wed, May 24, 2017 at 11:06:23AM +0200, Borislav Petkov wrote:
>> I'll send a new version soonish.
>
> Here's v2, I've dropped the testsuite stuff too as it is the assembler too.

We need assembler testcases.

> ---
> From: Borislav Petkov <bp@suse.de>
> Date: Tue, 16 May 2017 10:00:25 +0200
> Subject: [PATCH] X86: Disassemble primary opcode map's group 2 ModRM.reg == 6 aliases correctly
>
> The instructions are not documented in the Intel SDM but are documented
> in the AMD APM as an alias to the group 2, ModRM.reg == 4 variant.
>
> Both AMD and Intel CPUs execute the C[0-1] and D[0-3] instructions as
> expected, i.e., like the /4 aliases:
>
>   #include <stdio.h>
>
>   int main(void)
>   {
>           int a = 2;
>
>           printf ("a before: %d\n", a);
>
>           asm volatile(".byte 0xd0,0xf0"          /* SHL %al */
>                        : "+a" (a));
>
>           printf("a after : %d\n", a);
>
>           return 0;
>   }
>
>   $ ./a.out
>   a before: 2
>   a after : 4
>
> Changelog:
>
> opcodes/
> * i386-dis.c: Enable ModRM.reg /6 aliases.
> ---
>  opcodes/i386-dis.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
> index 3980c46ad19a..bfe83659f3a6 100644
> --- a/opcodes/i386-dis.c
> +++ b/opcodes/i386-dis.c
> @@ -3438,7 +3438,7 @@ static const struct dis386 reg_table[][8] = {
>      { "rcrA",  { Eb, Ib }, 0 },
>      { "shlA",  { Eb, Ib }, 0 },
>      { "shrA",  { Eb, Ib }, 0 },
> -    { Bad_Opcode },
> +    { "shlA",  { Eb, Ib }, 0 },
>      { "sarA",  { Eb, Ib }, 0 },
>    },
>    /* REG_C1 */
> @@ -3449,7 +3449,7 @@ static const struct dis386 reg_table[][8] = {
>      { "rcrQ",  { Ev, Ib }, 0 },
>      { "shlQ",  { Ev, Ib }, 0 },
>      { "shrQ",  { Ev, Ib }, 0 },
> -    { Bad_Opcode },
> +    { "shlQ",  { Ev, Ib }, 0 },
>      { "sarQ",  { Ev, Ib }, 0 },
>    },
>    /* REG_C6 */
> @@ -3482,7 +3482,7 @@ static const struct dis386 reg_table[][8] = {
>      { "rcrA",  { Eb, I1 }, 0 },
>      { "shlA",  { Eb, I1 }, 0 },
>      { "shrA",  { Eb, I1 }, 0 },
> -    { Bad_Opcode },
> +    { "shlA",  { Eb, I1 }, 0 },
>      { "sarA",  { Eb, I1 }, 0 },
>    },
>    /* REG_D1 */
> @@ -3493,7 +3493,7 @@ static const struct dis386 reg_table[][8] = {
>      { "rcrQ",  { Ev, I1 }, 0 },
>      { "shlQ",  { Ev, I1 }, 0 },
>      { "shrQ",  { Ev, I1 }, 0 },
> -    { Bad_Opcode },
> +    { "shlQ",  { Ev, I1 }, 0 },
>      { "sarQ",  { Ev, I1 }, 0 },
>    },
>    /* REG_D2 */
> @@ -3504,7 +3504,7 @@ static const struct dis386 reg_table[][8] = {
>      { "rcrA",  { Eb, CL }, 0 },
>      { "shlA",  { Eb, CL }, 0 },
>      { "shrA",  { Eb, CL }, 0 },
> -    { Bad_Opcode },
> +    { "shlA",  { Eb, CL }, 0 },
>      { "sarA",  { Eb, CL }, 0 },
>    },
>    /* REG_D3 */
> @@ -3515,7 +3515,7 @@ static const struct dis386 reg_table[][8] = {
>      { "rcrQ",  { Ev, CL }, 0 },
>      { "shlQ",  { Ev, CL }, 0 },
>      { "shrQ",  { Ev, CL }, 0 },
> -    { Bad_Opcode },
> +    { "shlQ",  { Ev, CL }, 0 },
>      { "sarQ",  { Ev, CL }, 0 },
>    },
>    /* REG_F6 */
> --
> 2.11.0
>
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
> --



-- 
H.J.



More information about the Binutils mailing list