From 3036c8991964674ca2407c543645d841ad431267 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 4 Dec 2019 10:40:02 +0100 Subject: x86: drop some stray/bogus DefaultSize Insns permitting only GPR operands (and hence implicit sizing when there's no suffix) don't ever have their DefaultSize attribute inspected, so it shouldn't be there in the first place. Additionally XBEGIN is like JMP, not CALL, and hence shouldn't be converted to 32-bit operand size in .code16gcc mode. While the same is true for SYSRET, it permitting more than one suffix makes it FLDENV- like, and hence rather than dropping the attribute, for now add it to the exclusion list to avoid it getting an operand size prefix emitted in .code16gcc mode. (This will be dealt with later, perhaps together with FLDENV and friends.) --- gas/ChangeLog | 7 +++++ gas/config/tc-i386.c | 4 ++- gas/testsuite/gas/i386/general.l | 55 ++++++++++++++++++++++++++++++++++------ gas/testsuite/gas/i386/general.s | 37 +++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 9 deletions(-) (limited to 'gas') diff --git a/gas/ChangeLog b/gas/ChangeLog index 45e8b8a..7307dc8 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +2019-12-04 Jan Beulich + + * config/tc-i386.c (process_suffix): Exclude SYSRET alongside + FLDENV et al. + * testsuite/gas/i386/general.s: Expand .code16gcc set of insns. + * testsuite/gas/i386/general.l: Adjust expectations. + 2019-11-22 Andrew Burgess * as.c (flag_dwarf_cie_version): Change initial value to -1, and diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 120367d..64312d2 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -6311,7 +6311,9 @@ process_suffix (void) else if (i.tm.opcode_modifier.defaultsize && !i.suffix /* exclude fldenv/frstor/fsave/fstenv */ - && i.tm.opcode_modifier.no_ssuf) + && i.tm.opcode_modifier.no_ssuf + /* exclude sysret */ + && i.tm.base_opcode != 0x0f07) { if (stackop_size == LONG_MNEM_SUFFIX && i.tm.base_opcode == 0xcf) diff --git a/gas/testsuite/gas/i386/general.l b/gas/testsuite/gas/i386/general.l index ac17096..d5f74d1 100644 --- a/gas/testsuite/gas/i386/general.l +++ b/gas/testsuite/gas/i386/general.l @@ -31,6 +31,7 @@ .*:143: Warning:.* .*:144: Warning:.* .*:178: Warning:.* +.*:224: Warning:.* 1 .psize 0 2 .text 3 #test jumps and calls @@ -283,11 +284,49 @@ 217 022a 0FB6C8 movzb %al,%ecx 218 219 .code16gcc - 220 # Use 16-bit layout by default for fldenv. - 221 022d 67D920 fldenv \(%eax\) - 222 0230 67D920 fldenvs \(%eax\) - 223 0233 6766D920 fldenvl \(%eax\) - 224 - 225 # Force a good alignment. - 226 0237 00000000 00000000 .p2align 4,0 - 226 00 +[ ]*[1-9][0-9]*[ ]*# Except for IRET use 32-bit implicit stack accesses by default. +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+66E8FAFF FFFF[ ]+call \. +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+66FF17[ ]+call \*\(%bx\) +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+66C80000 00[ ]+enter \$0,\$0 +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+CF[ ]+iret +.*Warning:.*16-bit.*iret.* +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+66FF1F[ ]+lcall \*\(%bx\) +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+669A0000 00000000[ ]+lcall \$0,\$0 +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+66C9[ ]+leave +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+66CB[ ]+lret +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+66CA0000[ ]+lret \$0 +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+666A00[ ]+push \$0 +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+66683412 0000[ ]+push \$0x1234 +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+66FF37[ ]+push \(%bx\) +[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a-f]*[ ]+0F07[ ]+sysret +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+C7F8FCFF[ ]+xbegin \. +[ ]*[1-9][0-9]*[ ]* +[ ]*[1-9][0-9]*[ ]*# Use 16-bit layout by default for fldenv. +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+67D920[ ]+fldenv \(%eax\) +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+67D920[ ]+fldenvs \(%eax\) +[ ]*[1-9][0-9]*[ ]+[0-9a-f]*[ ]+6766D920[ ]+fldenvl \(%eax\) +[ ]*[1-9][0-9]*[ ]* +[ ]*[1-9][0-9]*[ ]*# Force a good alignment. +[ ]*[1-9][0-9]*[ ]+[0-9a-f ]+\.p2align 4,0 +#pass diff --git a/gas/testsuite/gas/i386/general.s b/gas/testsuite/gas/i386/general.s index e4b2530..add14fd 100644 --- a/gas/testsuite/gas/i386/general.s +++ b/gas/testsuite/gas/i386/general.s @@ -217,6 +217,43 @@ movzb %al,%ecx .code16gcc +# Except for IRET use 32-bit implicit stack accesses by default. + call . + call *(%bx) + enter $0,$0 + iret + lcall *(%bx) + lcall $0,$0 + leave + lret + lret $0 + push $0 + push $0x1234 + push (%bx) + pusha + pushf + pop (%bx) + popa + popf + ret + ret $0 + +# However use 16-bit branches not accessing the stack by default. + ja . + ja .+0x1234 + jcxz . + jmp . + jmp .+0x1234 + jmp *(%bx) + ljmp *(%bx) + ljmp $0,$0 + loop . + syscall + sysenter + sysexit + sysret + xbegin . + # Use 16-bit layout by default for fldenv. fldenv (%eax) fldenvs (%eax) -- cgit v1.1