aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-02-10 08:37:22 -0800
committerH.J. Lu <hjl.tools@gmail.com>2020-02-10 08:37:36 -0800
commit4b5aaf5f6992319c2c72e080a1a55842640b8732 (patch)
treeb75a8c08300589ff7d3f6fb820be4d56fe8a1f54 /gas
parent3a5d12fbb4f7888525978f9fba46b977afabe391 (diff)
downloadfsf-binutils-gdb-4b5aaf5f6992319c2c72e080a1a55842640b8732.zip
fsf-binutils-gdb-4b5aaf5f6992319c2c72e080a1a55842640b8732.tar.gz
fsf-binutils-gdb-4b5aaf5f6992319c2c72e080a1a55842640b8732.tar.bz2
x86: Accept Intel64 only instruction by default
Commit d835a58baae720 disabled sysenter/sysenter in 64-bit mode by default. By default, assembler should accept common, Intel64 only and AMD64 ISAs since there are no conflicts. gas/ PR gas/25516 * config/tc-i386.c (intel64): Renamed to ... (isa64): This. (match_template): Accept Intel64 only instruction by default. (i386_displacement): Updated. (md_parse_option): Updated. * c-i386.texi: Update -mamd64/-mintel64 documentation. * testsuite/gas/i386/i386.exp: Run x86-64-sysenter. Pass -mamd64 to x86-64-sysenter-amd. * testsuite/gas/i386/x86-64-sysenter.d: New file. opcodes/ PR gas/25516 * i386-gen.c (opcode_modifiers): Replace AMD64 and Intel64 with ISA64. * i386-opc.h (AMD64): Removed. (Intel64): Likewose. (AMD64): New. (INTEL64): Likewise. (INTEL64ONLY): Likewise. (i386_opcode_modifier): Replace amd64 and intel64 with isa64. * i386-opc.tbl (Amd64): New. (Intel64): Likewise. (Intel64Only): Likewise. Replace AMD64 with Amd64. Update sysenter/sysenter with Cpu64 and Intel64Only. Remove AMD64 from sysenter/sysenter. * i386-tbl.h: Regenerated.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog13
-rw-r--r--gas/config/tc-i386.c40
-rw-r--r--gas/doc/c-i386.texi3
-rw-r--r--gas/testsuite/gas/i386/i386.exp3
-rw-r--r--gas/testsuite/gas/i386/x86-64-sysenter.d5
5 files changed, 52 insertions, 12 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index a07d9b7..d7d91a4 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,16 @@
+2020-02-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR gas/25516
+ * config/tc-i386.c (intel64): Renamed to ...
+ (isa64): This.
+ (match_template): Accept Intel64 only instruction by default.
+ (i386_displacement): Updated.
+ (md_parse_option): Updated.
+ * c-i386.texi: Update -mamd64/-mintel64 documentation.
+ * testsuite/gas/i386/i386.exp: Run x86-64-sysenter. Pass
+ -mamd64 to x86-64-sysenter-amd.
+ * testsuite/gas/i386/x86-64-sysenter.d: New file.
+
2020-02-10 Alan Modra <amodra@gmail.com>
* config/obj-elf.c (obj_elf_change_section): Error for section
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 945ceb2..543fe25 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -598,9 +598,11 @@ static int shared = 0;
0 if att syntax. */
static int intel_syntax = 0;
-/* 1 for Intel64 ISA,
- 0 if AMD64 ISA. */
-static int intel64;
+static enum x86_64_isa
+{
+ amd64 = 1, /* AMD64 ISA. */
+ intel64 /* Intel64 ISA. */
+} isa64;
/* 1 for intel mnemonic,
0 if att mnemonic. */
@@ -5805,14 +5807,32 @@ match_template (char mnem_suffix)
if (intel_mnemonic && t->opcode_modifier.attmnemonic)
continue;
- /* Check AT&T/Intel syntax and Intel64/AMD64 ISA. */
+ /* Check AT&T/Intel syntax. */
i.error = unsupported_syntax;
if ((intel_syntax && t->opcode_modifier.attsyntax)
- || (!intel_syntax && t->opcode_modifier.intelsyntax)
- || (intel64 && t->opcode_modifier.amd64)
- || (!intel64 && t->opcode_modifier.intel64))
+ || (!intel_syntax && t->opcode_modifier.intelsyntax))
continue;
+ /* Check Intel64/AMD64 ISA. */
+ switch (isa64)
+ {
+ default:
+ /* Default: Don't accept Intel64. */
+ if (t->opcode_modifier.isa64 == INTEL64)
+ continue;
+ break;
+ case amd64:
+ /* -mamd64: Don't accept Intel64 and Intel64 only. */
+ if (t->opcode_modifier.isa64 >= INTEL64)
+ continue;
+ break;
+ case intel64:
+ /* -mintel64: Don't accept AMD64. */
+ if (t->opcode_modifier.isa64 == AMD64)
+ continue;
+ break;
+ }
+
/* Check the suffix. */
i.error = invalid_instruction_suffix;
if ((t->opcode_modifier.no_bsuf && suffix_check.no_bsuf)
@@ -9963,7 +9983,7 @@ i386_displacement (char *disp_start, char *disp_end)
if (t->opcode_modifier.jump
!= current_templates->start->opcode_modifier.jump)
break;
- if (t->opcode_modifier.intel64)
+ if ((t->opcode_modifier.isa64 >= INTEL64))
has_intel64 = TRUE;
}
if (t < current_templates->end)
@@ -12525,11 +12545,11 @@ md_parse_option (int c, const char *arg)
break;
case OPTION_MAMD64:
- intel64 = 0;
+ isa64 = amd64;
break;
case OPTION_MINTEL64:
- intel64 = 1;
+ isa64 = intel64;
break;
case 'O':
diff --git a/gas/doc/c-i386.texi b/gas/doc/c-i386.texi
index 9fb681e..f0189cc 100644
--- a/gas/doc/c-i386.texi
+++ b/gas/doc/c-i386.texi
@@ -488,7 +488,8 @@ with 01, 10 and 11 RC bits, respectively.
@item -mamd64
@itemx -mintel64
This option specifies that the assembler should accept only AMD64 or
-Intel64 ISA in 64-bit mode. The default is to accept both.
+Intel64 ISA in 64-bit mode. The default is to accept common, Intel64
+only and AMD64 ISAs.
@cindex @samp{-O0} option, i386
@cindex @samp{-O0} option, x86-64
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 59b1415..c428041 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -728,10 +728,11 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
run_dump_test "x86-64-nops-5"
run_dump_test "x86-64-nops-5-k8"
run_dump_test "x86-64-nops-7"
+ run_dump_test "x86-64-sysenter"
run_dump_test "x86-64-sysenter-intel"
run_dump_test "x86-64-sysenter-mixed"
run_dump_test "x86-64-sysenter-amd"
- run_list_test "x86-64-sysenter-amd"
+ run_list_test "x86-64-sysenter-amd" "-mamd64"
run_dump_test "noreg64"
run_list_test "noreg64"
run_list_test "cvtsi2sX"
diff --git a/gas/testsuite/gas/i386/x86-64-sysenter.d b/gas/testsuite/gas/i386/x86-64-sysenter.d
new file mode 100644
index 0000000..65d21a0
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-sysenter.d
@@ -0,0 +1,5 @@
+#as:
+#objdump: -dw
+#name: x86-64 sysenter (Default)
+#source: x86-64-sysenter-amd.s
+#dump: x86-64-sysenter-intel.d