aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2023-10-23 10:29:54 +0200
committerJan Beulich <jbeulich@suse.com>2023-10-23 10:29:54 +0200
commitd12c7ab814cdb61da22c8d362e109ed55982a74b (patch)
tree6f7aa115bad8d469f0abf2875baad50e2257ce4c
parented71929492f2219ef116ad43b4c36d08249aee93 (diff)
downloadgdb-d12c7ab814cdb61da22c8d362e109ed55982a74b.zip
gdb-d12c7ab814cdb61da22c8d362e109ed55982a74b.tar.gz
gdb-d12c7ab814cdb61da22c8d362e109ed55982a74b.tar.bz2
x86: i386_generate_nops() may not derive decisions from global variables
What matters is what was in effect at the time the original directive was issued. Later changes to global state (bitness or ISA) must not affect what code is generated.
-rw-r--r--gas/config/tc-i386.c4
-rw-r--r--gas/testsuite/gas/i386/i386.exp1
-rw-r--r--gas/testsuite/gas/i386/nops-10.d13
-rw-r--r--gas/testsuite/gas/i386/nops-10.s6
-rw-r--r--gas/testsuite/gas/i386/x86-64-nops-6.d13
-rw-r--r--gas/testsuite/gas/i386/x86-64-nops-6.s7
-rw-r--r--gas/testsuite/gas/i386/x86-64.exp1
7 files changed, 43 insertions, 2 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index d54e9df..d7eea9d 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -1434,7 +1434,7 @@ i386_generate_nops (fragS *fragP, char *where, offsetT count, int limit)
When -march= or .arch is used, we can't use anything beyond
cpu_arch_isa_flags. */
- if (flag_code == CODE_16BIT)
+ if (fragP->tc_frag_data.code == CODE_16BIT)
{
patt = f16_patt;
max_single_nop_size = sizeof (f16_patt) / sizeof (f16_patt[0]);
@@ -1446,7 +1446,7 @@ i386_generate_nops (fragS *fragP, char *where, offsetT count, int limit)
if (fragP->tc_frag_data.isa == PROCESSOR_UNKNOWN)
{
/* PROCESSOR_UNKNOWN means that all ISAs may be used. */
- switch (cpu_arch_tune)
+ switch (fragP->tc_frag_data.tune)
{
case PROCESSOR_UNKNOWN:
/* We use cpu_arch_isa_flags to check if we SHOULD
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index ee74bcd..1072c07 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -148,6 +148,7 @@ if [gas_32_check] then {
run_dump_test "nops-7"
run_dump_test "nops-8"
run_dump_test "nops-9"
+ run_dump_test "nops-10"
run_dump_test "noreg16"
run_list_test "noreg16"
run_dump_test "noreg16-data32"
diff --git a/gas/testsuite/gas/i386/nops-10.d b/gas/testsuite/gas/i386/nops-10.d
new file mode 100644
index 0000000..b464275
--- /dev/null
+++ b/gas/testsuite/gas/i386/nops-10.d
@@ -0,0 +1,13 @@
+#objdump: -drw
+#name: nops 10
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <default>:
+[ ]*[a-f0-9]+: 0f be f0 movsbl %al,%esi
+[ ]*[a-f0-9]+: 8d b4 26 00 00 00 00 lea 0x0\(%esi,%eiz,1\),%esi
+[ ]*[a-f0-9]+: 8d b6 00 00 00 00 lea 0x0\(%esi\),%esi
+#pass
diff --git a/gas/testsuite/gas/i386/nops-10.s b/gas/testsuite/gas/i386/nops-10.s
new file mode 100644
index 0000000..35a300a
--- /dev/null
+++ b/gas/testsuite/gas/i386/nops-10.s
@@ -0,0 +1,6 @@
+ .text
+default:
+ movsbl %al,%esi
+ .p2align 4
+
+ .code16
diff --git a/gas/testsuite/gas/i386/x86-64-nops-6.d b/gas/testsuite/gas/i386/x86-64-nops-6.d
new file mode 100644
index 0000000..e962350
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-nops-6.d
@@ -0,0 +1,13 @@
+#objdump: -drw
+#name: x86-64 nops 6
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <default>:
+[ ]*[a-f0-9]+: 0f be f0 movsbl %al,%esi
+[ ]*[a-f0-9]+: 66 66 2e 0f 1f 84 00 00 00 00 00 data16 cs nopw (0x)?0\(%rax,%rax,1\)
+[ ]*[a-f0-9]+: 66 90 xchg %ax,%ax
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-nops-6.s b/gas/testsuite/gas/i386/x86-64-nops-6.s
new file mode 100644
index 0000000..b6dc7ad
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-nops-6.s
@@ -0,0 +1,7 @@
+ .text
+default:
+ movsbl %al,%esi
+ .p2align 4
+
+ .code32
+ .arch generic32
diff --git a/gas/testsuite/gas/i386/x86-64.exp b/gas/testsuite/gas/i386/x86-64.exp
index 52711cd..3d521f6 100644
--- a/gas/testsuite/gas/i386/x86-64.exp
+++ b/gas/testsuite/gas/i386/x86-64.exp
@@ -116,6 +116,7 @@ run_dump_test "x86-64-nops-4-core2"
run_dump_test "x86-64-nops-4-k8"
run_dump_test "x86-64-nops-5"
run_dump_test "x86-64-nops-5-k8"
+run_dump_test "x86-64-nops-6"
run_dump_test "x86-64-nops-7"
run_dump_test "x86-64-sysenter"
run_dump_test "x86-64-sysenter-intel"