x86-64/Intel: fix CALL/JMP with dword operand
authorJan Beulich <jbeulich@suse.com>
Wed, 4 Dec 2019 09:44:27 +0000 (10:44 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 4 Dec 2019 09:44:27 +0000 (10:44 +0100)
While dc2be329b950 ("i386: Only check suffix in instruction mnemonic")
has made the assembler accept these in the first place (they were wrongly
rejected before), the generated code was still wrong in that it lacked
an operand size override. (In 64-bit code, other than in 16- and 32-bit
ones, CALL and JMP with memory operands are all entirely unambiguous: No
operand size can have two meanings.)

gas/ChangeLog
gas/config/tc-i386-intel.c
gas/testsuite/gas/i386/x86-64-jump.d
gas/testsuite/gas/i386/x86-64-jump.s

index dba3faac802fb7d953a8dd4b0ffebe9795719305..d309806521ed9b1b7e64eb684ad719b6ba050ad2 100644 (file)
@@ -1,3 +1,11 @@
+2019-12-04  Jan Beulich  <jbeulich@suse.com>
+
+       * config/tc-i386-intel.c (i386_intel_operand): Also handle DWORD
+       with 64-bit mode branches.
+       * testsuite/gas/i386/x86-64-jump.s: Extend Intel syntax branch
+       operand coverage.
+       * testsuite/gas/i386/x86-64-jump.d: Adjust expectations.
+
 2019-12-04  Jan Beulich  <jbeulich@suse.com>
 
        * config/tc-i386.c (output_insn): Don't consider Cpu* settings
index 49f558d2785e2beea033c7ff4978f36fb4cfd84f..51fa38d91f65672f7e1361ad4df88224123ceb64 100644 (file)
@@ -657,11 +657,12 @@ i386_intel_operand (char *operand_string, int got_a_float)
               && current_templates->start->name[3] == 0)
              || current_templates->start->base_opcode == 0x62 /* bound */)
            suffix = WORD_MNEM_SUFFIX;
-         else if (flag_code == CODE_16BIT
+         else if (flag_code != CODE_32BIT
                   && (current_templates->start->opcode_modifier.jump == JUMP
                       || current_templates->start->opcode_modifier.jump
                          == JUMP_DWORD))
-           suffix = LONG_DOUBLE_MNEM_SUFFIX;
+           suffix = flag_code == CODE_16BIT ? LONG_DOUBLE_MNEM_SUFFIX
+                                            : WORD_MNEM_SUFFIX;
          else if (got_a_float == 1)    /* "f..." */
            suffix = SHORT_MNEM_SUFFIX;
          else
index c771e5e0110e1a784e85928e8ec4c82989298f21..1a1521d2782282ad046b0ea8c6ae1584c91f9215 100644 (file)
@@ -31,14 +31,22 @@ Disassembly of section .text:
 [      ]*[a-f0-9]+:    e3 00                   jrcxz  0x69     68: R_X86_64_PC8        \$\+0x1
 [      ]*[a-f0-9]+:    90                      nop
 [      ]*[a-f0-9]+:    66 ff 13                callw  \*\(%rbx\)
+[      ]*[a-f0-9]+:    66 ff 1b                lcallw \*\(%rbx\)
+[      ]*[a-f0-9]+:    ff 1b                   lcall  \*\(%rbx\)
+[      ]*[a-f0-9]+:    ff 13                   callq  \*\(%rbx\)
+[      ]*[a-f0-9]+:    ff 13                   callq  \*\(%rbx\)
 [      ]*[a-f0-9]+:    ff 1b                   lcall  \*\(%rbx\)
 [      ]*[a-f0-9]+:    66 ff 23                jmpw   \*\(%rbx\)
+[      ]*[a-f0-9]+:    66 ff 2b                ljmpw  \*\(%rbx\)
+[      ]*[a-f0-9]+:    ff 2b                   ljmp   \*\(%rbx\)
+[      ]*[a-f0-9]+:    ff 23                   jmpq   \*\(%rbx\)
+[      ]*[a-f0-9]+:    ff 23                   jmpq   \*\(%rbx\)
 [      ]*[a-f0-9]+:    ff 2b                   ljmp   \*\(%rbx\)
-[      ]*[a-f0-9]+:    eb 00                   jmp    0x76
+[      ]*[a-f0-9]+:    eb 00                   jmp    0x[0-9a-f]*
 [      ]*[a-f0-9]+:    90                      nop
-[      ]*[a-f0-9]+:    67 e3 00                jecxz  0x7a
+[      ]*[a-f0-9]+:    67 e3 00                jecxz  0x[0-9a-f]*
 [      ]*[a-f0-9]+:    90                      nop
-[      ]*[a-f0-9]+:    e3 00                   jrcxz  0x7d
+[      ]*[a-f0-9]+:    e3 00                   jrcxz  0x[0-9a-f]*
 [      ]*[a-f0-9]+:    90                      nop
-[      ]*[a-f0-9]+:    eb 00                   jmp    0x80
+[      ]*[a-f0-9]+:    eb 00                   jmp    0x[0-9a-f]*
 #pass
index 96ae66e1c9849fa0710d1f78c61091f271ad986c..104ed53d0807b8b9a4606519be8ebec05a403220 100644 (file)
 
        .intel_syntax noprefix
        call    word ptr [rbx]
+       call    dword ptr [rbx]
        call    fword ptr [rbx]
+       call    qword ptr [rbx]
+       call    near ptr [rbx]
+       call    far ptr [rbx]
        jmp     word ptr [rbx]
+       jmp     dword ptr [rbx]
        jmp     fword ptr [rbx]
+       jmp     qword ptr [rbx]
+       jmp     near ptr [rbx]
+       jmp     far ptr [rbx]
        jmp     $+2
        nop
        jecxz   3+$
This page took 0.027731 seconds and 4 git commands to generate.