mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 04:49:54 +08:00
x86: also disallow non-byte/-word registers with byte/word suffix
Along the lines of be4c5e58bd ("x86: Always disallow double word suffix with word general register") also adjust check_{byte,word}_reg(), to make overall behavior consistent again in this regard.
This commit is contained in:
@ -1,3 +1,18 @@
|
|||||||
|
2020-02-12 Jan Beulich <jbeulich@suse.com>
|
||||||
|
|
||||||
|
PR gas/25438
|
||||||
|
* config/tc-i386.c (REGISTER_WARNINGS): Delete.
|
||||||
|
(check_byte_reg): Skip only source operand of CRC32. Drop Non-
|
||||||
|
64-bit-only warning.
|
||||||
|
(check_word_reg): Consistently error on mismatching register
|
||||||
|
size and suffix.
|
||||||
|
* testsuite/gas/i386/general.s: Replace dword GPR with word one
|
||||||
|
for movw. Replace suffix / GPR for orb.
|
||||||
|
* testsuite/gas/i386/inval.s: Add tests for movw with dword and
|
||||||
|
byte GPRs as well as ones for inb/outb with a word accumulator.
|
||||||
|
* testsuite/gas/i386/general.l, testsuite/gas/i386/intelbad.l,
|
||||||
|
testsuite/gas/i386/inval.l: Adjust expectations.
|
||||||
|
|
||||||
2020-02-12 Jan Beulich <jbeulich@suse.com>
|
2020-02-12 Jan Beulich <jbeulich@suse.com>
|
||||||
|
|
||||||
* config/tc-i386.c (operand_type_register_match): Also fall
|
* config/tc-i386.c (operand_type_register_match): Also fall
|
||||||
|
@ -44,10 +44,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef REGISTER_WARNINGS
|
|
||||||
#define REGISTER_WARNINGS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef INFER_ADDR_PREFIX
|
#ifndef INFER_ADDR_PREFIX
|
||||||
#define INFER_ADDR_PREFIX 1
|
#define INFER_ADDR_PREFIX 1
|
||||||
#endif
|
#endif
|
||||||
@ -6638,31 +6634,10 @@ check_byte_reg (void)
|
|||||||
&& i.tm.operand_types[op].bitfield.word)
|
&& i.tm.operand_types[op].bitfield.word)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* crc32 doesn't generate this warning. */
|
/* crc32 only wants its source operand checked here. */
|
||||||
if (i.tm.base_opcode == 0xf20f38f0)
|
if (i.tm.base_opcode == 0xf20f38f0 && op)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((i.types[op].bitfield.word
|
|
||||||
|| i.types[op].bitfield.dword
|
|
||||||
|| i.types[op].bitfield.qword)
|
|
||||||
&& i.op[op].regs->reg_num < 4
|
|
||||||
/* Prohibit these changes in 64bit mode, since the lowering
|
|
||||||
would be more complicated. */
|
|
||||||
&& flag_code != CODE_64BIT)
|
|
||||||
{
|
|
||||||
#if REGISTER_WARNINGS
|
|
||||||
if (!quiet_warnings)
|
|
||||||
as_warn (_("using `%s%s' instead of `%s%s' due to `%c' suffix"),
|
|
||||||
register_prefix,
|
|
||||||
(i.op[op].regs + (i.types[op].bitfield.word
|
|
||||||
? REGNAM_AL - REGNAM_AX
|
|
||||||
: REGNAM_AL - REGNAM_EAX))->reg_name,
|
|
||||||
register_prefix,
|
|
||||||
i.op[op].regs->reg_name,
|
|
||||||
i.suffix);
|
|
||||||
#endif
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* Any other register is bad. */
|
/* Any other register is bad. */
|
||||||
if (i.types[op].bitfield.class == Reg
|
if (i.types[op].bitfield.class == Reg
|
||||||
|| i.types[op].bitfield.class == RegMMX
|
|| i.types[op].bitfield.class == RegMMX
|
||||||
@ -6818,30 +6793,18 @@ check_word_reg (void)
|
|||||||
i.suffix);
|
i.suffix);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Warn if the e or r prefix on a general reg is present. */
|
/* Error if the e or r prefix on a general reg is present. */
|
||||||
else if ((!quiet_warnings || flag_code == CODE_64BIT)
|
else if ((i.types[op].bitfield.dword
|
||||||
&& (i.types[op].bitfield.dword
|
|
||||||
|| i.types[op].bitfield.qword)
|
|| i.types[op].bitfield.qword)
|
||||||
&& (i.tm.operand_types[op].bitfield.class == Reg
|
&& (i.tm.operand_types[op].bitfield.class == Reg
|
||||||
|| i.tm.operand_types[op].bitfield.instance == Accum)
|
|| i.tm.operand_types[op].bitfield.instance == Accum)
|
||||||
&& i.tm.operand_types[op].bitfield.word)
|
&& i.tm.operand_types[op].bitfield.word)
|
||||||
{
|
|
||||||
/* Prohibit these changes in the 64bit mode, since the
|
|
||||||
lowering is more complicated. */
|
|
||||||
if (flag_code == CODE_64BIT)
|
|
||||||
{
|
{
|
||||||
as_bad (_("incorrect register `%s%s' used with `%c' suffix"),
|
as_bad (_("incorrect register `%s%s' used with `%c' suffix"),
|
||||||
register_prefix, i.op[op].regs->reg_name,
|
register_prefix, i.op[op].regs->reg_name,
|
||||||
i.suffix);
|
i.suffix);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#if REGISTER_WARNINGS
|
|
||||||
as_warn (_("using `%s%s' instead of `%s%s' due to `%c' suffix"),
|
|
||||||
register_prefix,
|
|
||||||
(i.op[op].regs + REGNAM_AX - REGNAM_EAX)->reg_name,
|
|
||||||
register_prefix, i.op[op].regs->reg_name, i.suffix);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,12 +9,6 @@
|
|||||||
.*:25: Warning:.*
|
.*:25: Warning:.*
|
||||||
.*:27: Warning:.*
|
.*:27: Warning:.*
|
||||||
.*:29: Warning:.*
|
.*:29: Warning:.*
|
||||||
.*:48: Warning:.*
|
|
||||||
.*:51: Warning:.*
|
|
||||||
.*:124: Warning:.*
|
|
||||||
.*:125: Warning:.*
|
|
||||||
.*:126: Warning:.*
|
|
||||||
.*:127: Warning:.*
|
|
||||||
.*:128: Warning:.*
|
.*:128: Warning:.*
|
||||||
.*:129: Warning:.*
|
.*:129: Warning:.*
|
||||||
.*:130: Warning:.*
|
.*:130: Warning:.*
|
||||||
@ -90,12 +84,10 @@
|
|||||||
45 008d 661F popw %ds
|
45 008d 661F popw %ds
|
||||||
46 008f 668CD8 mov %ds,%ax
|
46 008f 668CD8 mov %ds,%ax
|
||||||
47 0092 668CD8 movw %ds,%ax
|
47 0092 668CD8 movw %ds,%ax
|
||||||
48 0095 668CD8 movw %ds,%eax
|
48 0095 668CDF movw %ds,%di
|
||||||
.*Warning:.*
|
|
||||||
49 0098 8ED8 mov %ax,%ds
|
49 0098 8ED8 mov %ax,%ds
|
||||||
50 009a 8ED8 movw %ax,%ds
|
50 009a 8ED8 movw %ax,%ds
|
||||||
51 009c 8ED8 movw %eax,%ds
|
51 009c 8EDF movw %di,%ds
|
||||||
.*Warning:.*
|
|
||||||
52
|
52
|
||||||
53 # test various pushes
|
53 # test various pushes
|
||||||
54 009e 6A0A pushl \$10
|
54 009e 6A0A pushl \$10
|
||||||
@ -167,15 +159,11 @@
|
|||||||
120 012e 0F9303 setaeb \(%ebx\)
|
120 012e 0F9303 setaeb \(%ebx\)
|
||||||
121 0131 0F93C0 setae %al
|
121 0131 0F93C0 setae %al
|
||||||
122
|
122
|
||||||
123 #these should give warnings
|
123 0134 0C01 orb \$1,%al
|
||||||
124 0134 0C01 orb \$1,%ax
|
124 0136 0D000100 00 orl \$0x100,%eax
|
||||||
.*Warning:.*
|
125 013b 80CB01 orb \$1,%bl
|
||||||
125 0136 0C01 orb \$1,%eax
|
126
|
||||||
.*Warning:.*
|
127 #these should give warnings
|
||||||
126 0138 80CB01 orb \$1,%bx
|
|
||||||
.*Warning:.*
|
|
||||||
127 013b 80CB01 orb \$1,%ebx
|
|
||||||
.*Warning:.*
|
|
||||||
128 013e D9C1 fldl %st\(1\)
|
128 013e D9C1 fldl %st\(1\)
|
||||||
.*Warning:.*
|
.*Warning:.*
|
||||||
129 0140 DDD2 fstl %st\(2\)
|
129 0140 DDD2 fstl %st\(2\)
|
||||||
|
@ -45,10 +45,10 @@
|
|||||||
popw %ds
|
popw %ds
|
||||||
mov %ds,%ax
|
mov %ds,%ax
|
||||||
movw %ds,%ax
|
movw %ds,%ax
|
||||||
movw %ds,%eax
|
movw %ds,%di
|
||||||
mov %ax,%ds
|
mov %ax,%ds
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
movw %eax,%ds
|
movw %di,%ds
|
||||||
|
|
||||||
# test various pushes
|
# test various pushes
|
||||||
pushl $10
|
pushl $10
|
||||||
@ -120,11 +120,11 @@
|
|||||||
setaeb (%ebx)
|
setaeb (%ebx)
|
||||||
setae %al
|
setae %al
|
||||||
|
|
||||||
|
orb $1,%al
|
||||||
|
orl $0x100,%eax
|
||||||
|
orb $1,%bl
|
||||||
|
|
||||||
#these should give warnings
|
#these should give warnings
|
||||||
orb $1,%ax
|
|
||||||
orb $1,%eax
|
|
||||||
orb $1,%bx
|
|
||||||
orb $1,%ebx
|
|
||||||
fldl %st(1)
|
fldl %st(1)
|
||||||
fstl %st(2)
|
fstl %st(2)
|
||||||
fstpl %st(3)
|
fstpl %st(3)
|
||||||
|
@ -154,7 +154,7 @@
|
|||||||
.*:172: Error: .*
|
.*:172: Error: .*
|
||||||
.*:174: Error: .*
|
.*:174: Error: .*
|
||||||
.*:175: Error: .*
|
.*:175: Error: .*
|
||||||
.*:176: Warning: .*
|
.*:176: Error: .*
|
||||||
.*:177: Error: .*
|
.*:177: Error: .*
|
||||||
.*:178: Error: .*
|
.*:178: Error: .*
|
||||||
.*:180: Error: .*
|
.*:180: Error: .*
|
||||||
|
@ -91,6 +91,12 @@
|
|||||||
.*:104: Error: .*
|
.*:104: Error: .*
|
||||||
.*:105: Error: .*
|
.*:105: Error: .*
|
||||||
.*:106: Error: .*
|
.*:106: Error: .*
|
||||||
|
.*:108: Error: .*
|
||||||
|
.*:109: Error: .*
|
||||||
|
.*:110: Error: .*
|
||||||
|
.*:112: Error: .*
|
||||||
|
.*:113: Error: .*
|
||||||
|
.*:114: Error: .*
|
||||||
GAS LISTING .*
|
GAS LISTING .*
|
||||||
|
|
||||||
|
|
||||||
@ -203,3 +209,14 @@ GAS LISTING .*
|
|||||||
[ ]*[1-9][0-9]*[ ]+movl %ds, %ax
|
[ ]*[1-9][0-9]*[ ]+movl %ds, %ax
|
||||||
[ ]*[1-9][0-9]*[ ]+movl %ax, %ds
|
[ ]*[1-9][0-9]*[ ]+movl %ax, %ds
|
||||||
[ ]*[1-9][0-9]*[ ]+movl %ax, %bx
|
[ ]*[1-9][0-9]*[ ]+movl %ax, %bx
|
||||||
|
[ ]*[1-9][0-9]*[ ]+
|
||||||
|
[ ]*[1-9][0-9]*[ ]+movw %ds, %eax
|
||||||
|
[ ]*[1-9][0-9]*[ ]+movw %eax, %ds
|
||||||
|
[ ]*[1-9][0-9]*[ ]+movw %eax, %ebx
|
||||||
|
[ ]*[1-9][0-9]*[ ]+
|
||||||
|
[ ]*[1-9][0-9]*[ ]+inb %dx, %ax
|
||||||
|
[ ]*[1-9][0-9]*[ ]+outb %ax, %dx
|
||||||
|
[ ]*[1-9][0-9]*[ ]+movb %ax, %bx
|
||||||
|
GAS LISTING .*
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,3 +104,11 @@ movnti word ptr [eax], ax
|
|||||||
movl %ds, %ax
|
movl %ds, %ax
|
||||||
movl %ax, %ds
|
movl %ax, %ds
|
||||||
movl %ax, %bx
|
movl %ax, %bx
|
||||||
|
|
||||||
|
movw %ds, %eax
|
||||||
|
movw %eax, %ds
|
||||||
|
movw %eax, %ebx
|
||||||
|
|
||||||
|
inb %dx, %ax
|
||||||
|
outb %ax, %dx
|
||||||
|
movb %ax, %bx
|
||||||
|
Reference in New Issue
Block a user