x86/Intel: issue diagnostics for redundant segment override prefixes
While we shouldn't outright reject such (as was wrongly done by commit
4d36230d59
("x86: Update segment register check in Intel syntax"), as
MASM accepts them even silently, issue (by default) a warning for such
questionable constructs.
This commit is contained in:
parent
e21440ba62
commit
fd4e034759
|
@ -1,3 +1,15 @@
|
|||
2017-11-29 Jan Beulich <jbeulich@suse.com>
|
||||
|
||||
PR gas/21874
|
||||
* config/tc-i386-intel.c (i386_intel_simplify): Chain together
|
||||
multiple segment override expressions.
|
||||
(i386_intel_operand): Issue diagnostic for redundant segment
|
||||
overrides.
|
||||
* testsuite/gas/i386/intelok.e: New.
|
||||
* testsuite/gas/i386/intelok.d: Reference intelok.e.
|
||||
* testsuite/gas/i386/inval-seg.s: Add redundant override checks.
|
||||
* testsuite/gas/i386/inval-seg.l: Adjust expectations.
|
||||
|
||||
2017-11-29 Jim Wilson <jimw@sifive.com>
|
||||
Palmer Dabbelt <palmer@sifive.com>
|
||||
|
||||
|
|
|
@ -413,7 +413,19 @@ static int i386_intel_simplify (expressionS *e)
|
|||
intel_state.index))
|
||||
return 0;
|
||||
if (!intel_state.in_offset)
|
||||
intel_state.seg = e->X_add_symbol;
|
||||
{
|
||||
if (!intel_state.seg)
|
||||
intel_state.seg = e->X_add_symbol;
|
||||
else
|
||||
{
|
||||
expressionS exp;
|
||||
|
||||
exp.X_op = O_full_ptr;
|
||||
exp.X_add_symbol = e->X_add_symbol;
|
||||
exp.X_op_symbol = intel_state.seg;
|
||||
intel_state.seg = make_expr_symbol (&exp);
|
||||
}
|
||||
}
|
||||
i386_intel_fold (e, e->X_op_symbol);
|
||||
break;
|
||||
|
||||
|
@ -956,10 +968,12 @@ i386_intel_operand (char *operand_string, int got_a_float)
|
|||
|
||||
if (intel_state.seg)
|
||||
{
|
||||
for (;;)
|
||||
for (ret = check_none; ; ret = operand_check)
|
||||
{
|
||||
expP = symbol_get_value_expression (intel_state.seg);
|
||||
if (expP->X_op != O_full_ptr)
|
||||
if (expP->X_op != O_full_ptr
|
||||
|| symbol_get_value_expression (expP->X_op_symbol)->X_op
|
||||
!= O_register)
|
||||
break;
|
||||
intel_state.seg = expP->X_add_symbol;
|
||||
}
|
||||
|
@ -974,6 +988,15 @@ i386_intel_operand (char *operand_string, int got_a_float)
|
|||
as_bad (_("invalid use of register"));
|
||||
return 0;
|
||||
}
|
||||
switch (ret)
|
||||
{
|
||||
case check_error:
|
||||
as_bad (_("redundant segment overrides"));
|
||||
return 0;
|
||||
case check_warning:
|
||||
as_warn (_("redundant segment overrides"));
|
||||
break;
|
||||
}
|
||||
switch (i386_regtab[expP->X_add_number].reg_num)
|
||||
{
|
||||
case 0: i.seg[i.mem_operands] = &es; break;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#as: -J --divide
|
||||
#objdump: -dwMintel
|
||||
#name: i386 intel-ok
|
||||
#stderr: intelok.e
|
||||
|
||||
.*: +file format .*
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
.*: Assembler messages:
|
||||
.*:153: Warning: redundant segment overrides
|
|
@ -1,10 +1,22 @@
|
|||
.*: Assembler messages:
|
||||
.*:3: Error: .*
|
||||
.*:4: Error: .*
|
||||
.*:7: Error: .*
|
||||
.*:8: Error: .*
|
||||
.*:9: Error: .*
|
||||
.*:10: Error: .*
|
||||
.*:11: Error: .*
|
||||
GAS LISTING .*
|
||||
|
||||
|
||||
1 [ ]* .text
|
||||
2 [ ]*# All the following should be illegal
|
||||
3 [ ]* movl %ds,\(%eax\)
|
||||
4 [ ]* movl \(%eax\),%ds
|
||||
[ ]*[1-9][0-9]*[ ]*\.text
|
||||
[ ]*[1-9][0-9]*[ ]*# All the following should be illegal
|
||||
[ ]*[1-9][0-9]*[ ]*movl %ds,\(%eax\)
|
||||
[ ]*[1-9][0-9]*[ ]*movl \(%eax\),%ds
|
||||
[ ]*[1-9][0-9]*[ ]*
|
||||
[ ]*[1-9][0-9]*[ ]*\.intel_syntax noprefix
|
||||
[ ]*[1-9][0-9]*[ ]*mov eax, es:foo:\[eax\]
|
||||
[ ]*[1-9][0-9]*[ ]*mov eax, es:fs:foo:\[eax\]
|
||||
[ ]*[1-9][0-9]*[ ]*mov eax, fs:foo:bar:\[eax\]
|
||||
[ ]*[1-9][0-9]*[ ]*mov eax, fs:foo:gs:\[eax\]
|
||||
[ ]*[1-9][0-9]*[ ]*mov eax, bar:gs:\[eax\]
|
||||
|
|
|
@ -2,3 +2,10 @@
|
|||
# All the following should be illegal
|
||||
movl %ds,(%eax)
|
||||
movl (%eax),%ds
|
||||
|
||||
.intel_syntax noprefix
|
||||
mov eax, es:foo:[eax]
|
||||
mov eax, es:fs:foo:[eax]
|
||||
mov eax, fs:foo:bar:[eax]
|
||||
mov eax, fs:foo:gs:[eax]
|
||||
mov eax, bar:gs:[eax]
|
||||
|
|
Loading…
Reference in New Issue