[PATCH] x86: Fix SYSRETQ disassembly

H.J. Lu hjl.tools@gmail.com
Sun Oct 4 21:05:53 GMT 2020


On Sun, Oct 4, 2020 at 2:01 PM Borislav Petkov <bp@suse.de> wrote:
>
> Disassembling this:
>
>   int main(void)
>   {
>
>         asm volatile("sysretq");
>         return 0;
>   }
>
> gives:
>
>   1129:       48 0f 07                rex.W sysret
>
> because the break condition in putop() which handles a %LQ (the template
> is "sysret%LQ") looks at ModRM.mod before verifying first that the
> instruction actually even has a ModRM byte and SYSRET doesn't, for
> example.
>
> Check need_modrm first before accessing a stale modrm value.

Which version of binutils are you using?  Binutils master branch gave:

Disassembly of section .text.startup:

0000000000000000 <main>:
   0: 48 0f 07              sysretq
   3: 31 c0                xor    %eax,%eax
   5: c3                    ret


-- 
H.J.


More information about the Binutils mailing list