diff options
author | Jan Beulich <jbeulich@novell.com> | 2017-11-30 11:46:26 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2017-11-30 11:46:26 +0100 |
commit | fd4e0347596acf79642625f4faad9e37c8fa0f0e (patch) | |
tree | 39f2f84e62f63adca731c80fa49179dc460c847e /gas | |
parent | e21440ba622e17a2f12a858a87a6a75ef90654ca (diff) | |
download | gdb-fd4e0347596acf79642625f4faad9e37c8fa0f0e.zip gdb-fd4e0347596acf79642625f4faad9e37c8fa0f0e.tar.gz gdb-fd4e0347596acf79642625f4faad9e37c8fa0f0e.tar.bz2 |
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.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 12 | ||||
-rw-r--r-- | gas/config/tc-i386-intel.c | 29 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/intelok.d | 1 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/intelok.e | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/inval-seg.l | 20 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/inval-seg.s | 7 |
6 files changed, 64 insertions, 7 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 1b6401f..a46f8de 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -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> diff --git a/gas/config/tc-i386-intel.c b/gas/config/tc-i386-intel.c index 74aae24..99d215e 100644 --- a/gas/config/tc-i386-intel.c +++ b/gas/config/tc-i386-intel.c @@ -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; diff --git a/gas/testsuite/gas/i386/intelok.d b/gas/testsuite/gas/i386/intelok.d index bad81e4..41e65b3 100644 --- a/gas/testsuite/gas/i386/intelok.d +++ b/gas/testsuite/gas/i386/intelok.d @@ -1,6 +1,7 @@ #as: -J --divide #objdump: -dwMintel #name: i386 intel-ok +#stderr: intelok.e .*: +file format .* diff --git a/gas/testsuite/gas/i386/intelok.e b/gas/testsuite/gas/i386/intelok.e new file mode 100644 index 0000000..585eaf4 --- /dev/null +++ b/gas/testsuite/gas/i386/intelok.e @@ -0,0 +1,2 @@ +.*: Assembler messages: +.*:153: Warning: redundant segment overrides diff --git a/gas/testsuite/gas/i386/inval-seg.l b/gas/testsuite/gas/i386/inval-seg.l index efe190e..c081b0e 100644 --- a/gas/testsuite/gas/i386/inval-seg.l +++ b/gas/testsuite/gas/i386/inval-seg.l @@ -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\] diff --git a/gas/testsuite/gas/i386/inval-seg.s b/gas/testsuite/gas/i386/inval-seg.s index 4cc2221..bf09d4d 100644 --- a/gas/testsuite/gas/i386/inval-seg.s +++ b/gas/testsuite/gas/i386/inval-seg.s @@ -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] |