x86-64: adjust far indirect branch handling

An unwanted side effect of 5990e377e5 ("x86-64: Intel64 adjustments
for insns dealing with far pointers") was that with -mintel64 LCALL and
LJMP would now default to 64-bit operand size. Since 64-bit far branches
aren't portable, the default operand size should still be 32-bit.
However, since the 64-bit variant is permitted, an ambiguous operand
warning should be issued.

As to the actual code change, please note that the conditional
surrounding the switch() that gets adjusted covers several cases which
are of no interest to or benign in 64-bit mode, hence the new
conditional added can be quite a bit less involved.
This commit is contained in:
Jan Beulich 2020-06-09 08:47:31 +02:00
parent da4977e00b
commit 828c2a2580
8 changed files with 160 additions and 1 deletions

View File

@ -1,3 +1,14 @@
2020-06-09 Jan Beulich <jbeulich@suse.com>
* config/tc-i386.c (process_suffix): Restrict defaulting to 'q'
suffix.
* testsuite/gas/i386/noreg64.s: Add lcall/ljmp cases.
* testsuite/gas/i386/noreg64.d: Adjust expectations.
* testsuite/gas/i386/noreg-intel64.d,
testsuite/gas/i386/noreg-intel64.l,
testsuite/gas/i386/noreg-intel64.s: New.
* testsuite/gas/i386/i386.exp: Run new tests.
2020-06-09 Jan Beulich <jbeulich@suse.com>
* config/tc-i386.c (vex_encoding_error): New enumerator.

View File

@ -6836,7 +6836,9 @@ process_suffix (void)
case CODE_64BIT:
if (!i.tm.opcode_modifier.no_qsuf)
{
i.suffix = QWORD_MNEM_SUFFIX;
if (i.tm.opcode_modifier.jump == JUMP_BYTE
|| i.tm.opcode_modifier.no_lsuf)
i.suffix = QWORD_MNEM_SUFFIX;
break;
}
/* Fall through. */

View File

@ -759,6 +759,8 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
run_list_test "x86-64-sysenter-amd" "-mamd64"
run_dump_test "noreg64"
run_list_test "noreg64"
run_dump_test "noreg-intel64"
run_list_test "noreg-intel64" "-I${srcdir}/$subdir -mintel64"
run_list_test "movx64" "-al"
run_list_test "cvtsi2sX"
run_dump_test "x86-64-sse4_1"

View File

@ -0,0 +1,5 @@
#as: -mintel64 -moperand-check=none
#objdump: -dw
#name: 64-bit insns not sizeable through register operands
#source: noreg64.s
#dump: noreg64.d

View File

@ -0,0 +1,134 @@
.*: Assembler messages:
.*:[1-9][0-9]*: Warning: .* `adc'
.*:[1-9][0-9]*: Warning: .* `adc'
.*:[1-9][0-9]*: Warning: .* `adc'
.*:[1-9][0-9]*: Warning: .* `adc'
.*:[1-9][0-9]*: Warning: .* `add'
.*:[1-9][0-9]*: Warning: .* `add'
.*:[1-9][0-9]*: Warning: .* `add'
.*:[1-9][0-9]*: Warning: .* `add'
.*:[1-9][0-9]*: Warning: .* `and'
.*:[1-9][0-9]*: Warning: .* `and'
.*:[1-9][0-9]*: Warning: .* `and'
.*:[1-9][0-9]*: Warning: .* `and'
.*:[1-9][0-9]*: Warning: .* `bt'
.*:[1-9][0-9]*: Warning: .* `btc'
.*:[1-9][0-9]*: Warning: .* `btr'
.*:[1-9][0-9]*: Warning: .* `bts'
.*:[1-9][0-9]*: Warning: .* `cmp'
.*:[1-9][0-9]*: Warning: .* `cmp'
.*:[1-9][0-9]*: Warning: .* `cmp'
.*:[1-9][0-9]*: Warning: .* `cmp'
.*:[1-9][0-9]*: Warning: .* `cmps'
.*:[1-9][0-9]*: Warning: .* `cmps'
.*:[1-9][0-9]*: Warning: .* `crc32'
.*:[1-9][0-9]*: Warning: .* `crc32'
.*:[1-9][0-9]*: Warning: .* `dec'
.*:[1-9][0-9]*: Warning: .* `div'
.*:[1-9][0-9]*: Warning: .* `fadd'
.*:[1-9][0-9]*: Warning: .* `fcom'
.*:[1-9][0-9]*: Warning: .* `fcomp'
.*:[1-9][0-9]*: Warning: .* `fdiv'
.*:[1-9][0-9]*: Warning: .* `fdivr'
.*:[1-9][0-9]*: Warning: .* `fiadd'
.*:[1-9][0-9]*: Warning: .* `ficom'
.*:[1-9][0-9]*: Warning: .* `ficomp'
.*:[1-9][0-9]*: Warning: .* `fidiv'
.*:[1-9][0-9]*: Warning: .* `fidivr'
.*:[1-9][0-9]*: Warning: .* `fild'
.*:[1-9][0-9]*: Warning: .* `fimul'
.*:[1-9][0-9]*: Warning: .* `fist'
.*:[1-9][0-9]*: Warning: .* `fistp'
.*:[1-9][0-9]*: Warning: .* `fisttp'
.*:[1-9][0-9]*: Warning: .* `fisub'
.*:[1-9][0-9]*: Warning: .* `fisubr'
.*:[1-9][0-9]*: Warning: .* `fld'
.*:[1-9][0-9]*: Warning: .* `fmul'
.*:[1-9][0-9]*: Warning: .* `fst'
.*:[1-9][0-9]*: Warning: .* `fstp'
.*:[1-9][0-9]*: Warning: .* `fsub'
.*:[1-9][0-9]*: Warning: .* `fsubr'
.*:[1-9][0-9]*: Warning: .* `idiv'
.*:[1-9][0-9]*: Warning: .* `imul'
.*:[1-9][0-9]*: Warning: .* `in'
.*:[1-9][0-9]*: Warning: .* `in'
.*:[1-9][0-9]*: Warning: .* `inc'
.*:[1-9][0-9]*: Warning: .* `ins'
.*:[1-9][0-9]*: Warning: .* `ins'
.*:[1-9][0-9]*: Warning: .* `iret'
.*:[1-9][0-9]*: Warning: .* `lcall'
.*:[1-9][0-9]*: Warning: .* `ljmp'
.*:[1-9][0-9]*: Warning: .* `lods'
.*:[1-9][0-9]*: Warning: .* `lods'
.*:[1-9][0-9]*: Warning: .* `lret'
.*:[1-9][0-9]*: Warning: .* `lret'
.*:[1-9][0-9]*: Warning: .* `mov'
.*:[1-9][0-9]*: Warning: .* `mov'
.*:[1-9][0-9]*: Warning: .* `mov'
.*:[1-9][0-9]*: Warning: .* `movs'
.*:[1-9][0-9]*: Warning: .* `movs'
.*:[1-9][0-9]*: Warning: .* `mul'
.*:[1-9][0-9]*: Warning: .* `neg'
.*:[1-9][0-9]*: Warning: .* `nop'
.*:[1-9][0-9]*: Warning: .* `not'
.*:[1-9][0-9]*: Warning: .* `or'
.*:[1-9][0-9]*: Warning: .* `or'
.*:[1-9][0-9]*: Warning: .* `or'
.*:[1-9][0-9]*: Warning: .* `or'
.*:[1-9][0-9]*: Warning: .* `out'
.*:[1-9][0-9]*: Warning: .* `out'
.*:[1-9][0-9]*: Warning: .* `outs'
.*:[1-9][0-9]*: Warning: .* `outs'
.*:[1-9][0-9]*: Warning: .* `ptwrite'
.*:[1-9][0-9]*: Warning: .* `rcl'
.*:[1-9][0-9]*: Warning: .* `rcl'
.*:[1-9][0-9]*: Warning: .* `rcl'
.*:[1-9][0-9]*: Warning: .* `rcl'
.*:[1-9][0-9]*: Warning: .* `rcr'
.*:[1-9][0-9]*: Warning: .* `rcr'
.*:[1-9][0-9]*: Warning: .* `rcr'
.*:[1-9][0-9]*: Warning: .* `rcr'
.*:[1-9][0-9]*: Warning: .* `rol'
.*:[1-9][0-9]*: Warning: .* `rol'
.*:[1-9][0-9]*: Warning: .* `rol'
.*:[1-9][0-9]*: Warning: .* `rol'
.*:[1-9][0-9]*: Warning: .* `ror'
.*:[1-9][0-9]*: Warning: .* `ror'
.*:[1-9][0-9]*: Warning: .* `ror'
.*:[1-9][0-9]*: Warning: .* `ror'
.*:[1-9][0-9]*: Warning: .* `sbb'
.*:[1-9][0-9]*: Warning: .* `sbb'
.*:[1-9][0-9]*: Warning: .* `sbb'
.*:[1-9][0-9]*: Warning: .* `sbb'
.*:[1-9][0-9]*: Warning: .* `scas'
.*:[1-9][0-9]*: Warning: .* `scas'
.*:[1-9][0-9]*: Warning: .* `sal'
.*:[1-9][0-9]*: Warning: .* `sal'
.*:[1-9][0-9]*: Warning: .* `sal'
.*:[1-9][0-9]*: Warning: .* `sal'
.*:[1-9][0-9]*: Warning: .* `sar'
.*:[1-9][0-9]*: Warning: .* `sar'
.*:[1-9][0-9]*: Warning: .* `sar'
.*:[1-9][0-9]*: Warning: .* `sar'
.*:[1-9][0-9]*: Warning: .* `shl'
.*:[1-9][0-9]*: Warning: .* `shl'
.*:[1-9][0-9]*: Warning: .* `shl'
.*:[1-9][0-9]*: Warning: .* `shl'
.*:[1-9][0-9]*: Warning: .* `shr'
.*:[1-9][0-9]*: Warning: .* `shr'
.*:[1-9][0-9]*: Warning: .* `shr'
.*:[1-9][0-9]*: Warning: .* `shr'
.*:[1-9][0-9]*: Warning: .* `stos'
.*:[1-9][0-9]*: Warning: .* `stos'
.*:[1-9][0-9]*: Warning: .* `sub'
.*:[1-9][0-9]*: Warning: .* `sub'
.*:[1-9][0-9]*: Warning: .* `sub'
.*:[1-9][0-9]*: Warning: .* `sub'
.*:[1-9][0-9]*: Warning: .* `sysret'
.*:[1-9][0-9]*: Warning: .* `test'
.*:[1-9][0-9]*: Warning: .* `test'
.*:[1-9][0-9]*: Warning: .* `test'
.*:[1-9][0-9]*: Warning: .* `xor'
.*:[1-9][0-9]*: Warning: .* `xor'
.*:[1-9][0-9]*: Warning: .* `xor'
.*:[1-9][0-9]*: Warning: .* `xor'

View File

@ -0,0 +1 @@
.include "noreg64.s"

View File

@ -66,8 +66,10 @@ Disassembly of section .text:
*[a-f0-9]+: 6d insl \(%dx\),%es:\(%rdi\)
*[a-f0-9]+: cf iret *
*[a-f0-9]+: ff 20 jmpq \*\(%rax\)
*[a-f0-9]+: ff 18 lcall \*\(%rax\)
*[a-f0-9]+: 0f 01 10 lgdt \(%rax\)
*[a-f0-9]+: 0f 01 18 lidt \(%rax\)
*[a-f0-9]+: ff 28 ljmp \*\(%rax\)
*[a-f0-9]+: 0f 00 10 lldt \(%rax\)
*[a-f0-9]+: 0f 01 30 lmsw \(%rax\)
*[a-f0-9]+: ad lods %ds:\(%rsi\),%eax

View File

@ -59,8 +59,10 @@ noreg:
ins %dx, %es:(%rdi)
iret
jmp *(%rax)
lcall *(%rax)
lgdt (%rax)
lidt (%rax)
ljmp *(%rax)
lldt (%rax)
lmsw (%rax)
lods