aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2020-11-14 06:16:26 -0800
committerH.J. Lu <hjl.tools@gmail.com>2020-11-14 06:20:33 -0800
commit0fa0fc8539f4451bd1ed76867ba87a335e28ff31 (patch)
treec010ef4ef967a84d7726f9d1b7f6231350e1e22c /opcodes
parente8b2f0d952184fac8a230db181a4b9810729cd7b (diff)
downloadfsf-binutils-gdb-0fa0fc8539f4451bd1ed76867ba87a335e28ff31.zip
fsf-binutils-gdb-0fa0fc8539f4451bd1ed76867ba87a335e28ff31.tar.gz
fsf-binutils-gdb-0fa0fc8539f4451bd1ed76867ba87a335e28ff31.tar.bz2
x86: Ignore CS/DS/ES/SS segment-override prefixes in 64-bit mode
"In 64-bit mode, the CS, DS, ES, and SS segment-override prefixes have no effect. These four prefixes are not treated as segment-override prefixes for the purposes of multiple-prefix rules. Instead, they are treated as null prefixes." (AMD APM v2). However, objdump disassembles instructions containing those ignored prefixes by still generating that segment override: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) 00 00 00 00 Print those segment override prefixes as excessive ones: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1) 00 00 00 00 which is what they actually are - they have no effect and the decoding hardware ignores them. gas/ 2020-11-14 Borislav Petkov <bp@suse.de> * testsuite/gas/i386/x86-64-segovr.d: Adjust regexes. * testsuite/gas/i386/x86-64-nops.d: Likewise. * testsuite/gas/i386/x86-64-nops-1.d: Likewise. * testsuite/gas/i386/x86-64-nops-1-g64.d: Likewise. * testsuite/gas/i386/x86-64-nops-1-core2.d: Likewise. * testsuite/gas/i386/x86-64-nops-1-k8.d: Likewise. * testsuite/gas/i386/x86-64-nops-2.d: Likewise. * testsuite/gas/i386/x86-64-nops-3.d: Likewise. * testsuite/gas/i386/x86-64-nops-4.d: Likewise. * testsuite/gas/i386/x86-64-nops-4-core2.d: Likewise. * testsuite/gas/i386/x86-64-nops-4-k8.d: Likewise. * testsuite/gas/i386/x86-64-nops-5.d: Likewise. * testsuite/gas/i386/x86-64-nops-5-k8.d: Likewise. * testsuite/gas/i386/x86-64-nops-7.d: Likewise. * testsuite/gas/i386/x86-64-nop-1.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-1a.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-1b.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-1c.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-1d.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-1g.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-2c.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-6.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-7.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-8.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-1-core2.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-1-k8.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-1.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-2.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-3.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-4-core2.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-4-k8.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-4.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-5-k8.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-5.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops.d:: Likewise. ld/ 2020-11-14 Borislav Petkov <bp@suse.de> * testsuite/ld-x86-64/pe-x86-64-4.od: Adjust regexes. * testsuite/ld-x86-64/tlsld3.dd: Likewise. * testsuite/ld-x86-64/tlsld4.dd: Likewise. opcodes/ 2020-11-14 Borislav Petkov <bp@suse.de> * i386-dis.c (ckprefix): Do not assign active_seg_prefix in 64-bit addressing mode. (NOTRACK_Fixup): Test prefixes for PREFIX_DS, instead of active_seg_prefix.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/ChangeLog7
-rw-r--r--opcodes/i386-dis.c25
2 files changed, 27 insertions, 5 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index d00e549..b25132a 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,10 @@
+2020-11-14 Borislav Petkov <bp@suse.de>
+
+ * i386-dis.c (ckprefix): Do not assign active_seg_prefix in
+ 64-bit addressing mode.
+ (NOTRACK_Fixup): Test prefixes for PREFIX_DS, instead of
+ active_seg_prefix.
+
2020-11-11 Przemyslaw Wirkus <przemyslaw.wirkus@arm.com>
* aarch64-tbl.h: Enable -march=armv8.6-a+ls64.
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 9338b1f..58cf001 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -9141,22 +9141,34 @@ ckprefix (void)
case 0x2e:
prefixes |= PREFIX_CS;
last_seg_prefix = i;
- active_seg_prefix = PREFIX_CS;
+
+ if (address_mode != mode_64bit)
+ active_seg_prefix = PREFIX_CS;
+
break;
case 0x36:
prefixes |= PREFIX_SS;
last_seg_prefix = i;
- active_seg_prefix = PREFIX_SS;
+
+ if (address_mode != mode_64bit)
+ active_seg_prefix = PREFIX_SS;
+
break;
case 0x3e:
prefixes |= PREFIX_DS;
last_seg_prefix = i;
- active_seg_prefix = PREFIX_DS;
+
+ if (address_mode != mode_64bit)
+ active_seg_prefix = PREFIX_DS;
+
break;
case 0x26:
prefixes |= PREFIX_ES;
last_seg_prefix = i;
- active_seg_prefix = PREFIX_ES;
+
+ if (address_mode != mode_64bit)
+ active_seg_prefix = PREFIX_ES;
+
break;
case 0x64:
prefixes |= PREFIX_FS;
@@ -13656,7 +13668,10 @@ static void
NOTRACK_Fixup (int bytemode ATTRIBUTE_UNUSED,
int sizeflag ATTRIBUTE_UNUSED)
{
- if (active_seg_prefix == PREFIX_DS
+
+ /* Since active_seg_prefix is not set in 64-bit mode, check whether
+ we've seen a PREFIX_DS. */
+ if ((prefixes & PREFIX_DS) != 0
&& (address_mode != mode_64bit || last_data_prefix < 0))
{
/* NOTRACK prefix is only valid on indirect branch instructions.