x86: extend LEA's segment override warning
authorJan Beulich <jbeulich@suse.com>
Fri, 14 Feb 2020 13:02:05 +0000 (14:02 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 14 Feb 2020 13:02:05 +0000 (14:02 +0100)
For one both possible forms should be warned about. And then, to guard
against future surprises, qualify the original opcode check by excluding
VEX/EVEX-like templates.

gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/i386.exp
gas/testsuite/gas/i386/lea.d [new file with mode: 0644]
gas/testsuite/gas/i386/lea.e [new file with mode: 0644]
gas/testsuite/gas/i386/lea.s [new file with mode: 0644]

index 67d137940f7d7c60e961291e1efef9a49fcd3972..4f1aeed7c7c158a6acc618a3b848d3e7849d63b8 100644 (file)
@@ -1,3 +1,12 @@
+2020-02-XX  Jan Beulich  <jbeulich@suse.com>
+
+       * config/tc-i386.c (process_operands): Also check insn prefix
+       for ineffectual segment override warning. Don't cover possible
+       VEX/EVEX encoded insns there.
+       * testsuite/gas/i386/lea.s, testsuite/gas/i386/lea.d,
+       testsuite/gas/i386/lea.e: New.
+       * testsuite/gas/i386/i386.exp: Run new test.
+
 2020-02-14  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR gas/25438
index 8e422fd2dc24c112ddedc9ed7e8d750a6d5a17f5..05151f2a6363d603a69e8ca34c1005bca05d3adb 100644 (file)
@@ -7164,9 +7164,10 @@ duplicate:
        }
     }
 
-  if (i.tm.base_opcode == 0x8d /* lea */
-      && i.seg[0]
-      && !quiet_warnings)
+  if ((i.seg[0] || i.prefix[SEG_PREFIX])
+      && !quiet_warnings
+      && i.tm.base_opcode == 0x8d /* lea */
+      && !is_any_vex_encoding(&i.tm))
     as_warn (_("segment override on `%s' is ineffectual"), i.tm.name);
 
   /* If a segment was explicitly specified, and the specified segment
index 8cace3dc9f87df9e8490b16321f6de0c906d4c85..147297e22f2a3a955154519e9beac4adab107d88 100644 (file)
@@ -65,6 +65,7 @@ if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]
     run_dump_test "intelok"
     run_dump_test "prefix"
     run_list_test "prefix32" "-al"
+    run_dump_test "lea"
     run_dump_test "amd"
     run_dump_test "katmai"
     run_dump_test "jump"
diff --git a/gas/testsuite/gas/i386/lea.d b/gas/testsuite/gas/i386/lea.d
new file mode 100644 (file)
index 0000000..aa0414b
--- /dev/null
@@ -0,0 +1,12 @@
+#objdump: -dw
+#name: i386 LEA-like warnings
+#warning_output: lea.e
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <start>:
+[      ]*[0-9a-f]+:[   ]+36 8d 00[     ]+lea[  ]+%ss:\(%eax\),%eax
+[      ]*[0-9a-f]+:[   ]+36 8d 00[     ]+lea[  ]+%ss:\(%eax\),%eax
+#pass
diff --git a/gas/testsuite/gas/i386/lea.e b/gas/testsuite/gas/i386/lea.e
new file mode 100644 (file)
index 0000000..be965b3
--- /dev/null
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*:3: Warning: .* `lea' .*
+.*:4: Warning: .* `lea' .*
diff --git a/gas/testsuite/gas/i386/lea.s b/gas/testsuite/gas/i386/lea.s
new file mode 100644 (file)
index 0000000..4324ad0
--- /dev/null
@@ -0,0 +1,4 @@
+       .text
+start:
+       lea     %ss:(%eax), %eax
+       ss lea  (%eax), %eax
This page took 0.031568 seconds and 4 git commands to generate.