From b22f4eaf74179ae25b47bde306dfa7cc34e23e55 Mon Sep 17 00:00:00 2001 From: Jos Date: Thu, 20 Nov 2025 18:05:54 +0100 Subject: [PATCH 1/5] Ignore ES/CS/SS/DS segment overrides in x64 mode --- arch/X86/X86DisassemblerDecoder.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/X86/X86DisassemblerDecoder.c b/arch/X86/X86DisassemblerDecoder.c index 0938d56130..3b141036f3 100644 --- a/arch/X86/X86DisassemblerDecoder.c +++ b/arch/X86/X86DisassemblerDecoder.c @@ -523,19 +523,27 @@ static int readPrefixes(struct InternalInstruction *insn) case 0x65: /* GS segment override */ switch (byte) { case 0x2e: - insn->segmentOverride = SEG_OVERRIDE_CS; + if (insn->mode != MODE_64BIT) { + insn->segmentOverride = SEG_OVERRIDE_CS; + } insn->prefix1 = byte; break; case 0x36: - insn->segmentOverride = SEG_OVERRIDE_SS; + if (insn->mode != MODE_64BIT) { + insn->segmentOverride = SEG_OVERRIDE_SS; + } insn->prefix1 = byte; break; case 0x3e: - insn->segmentOverride = SEG_OVERRIDE_DS; + if (insn->mode != MODE_64BIT) { + insn->segmentOverride = SEG_OVERRIDE_DS; + } insn->prefix1 = byte; break; case 0x26: - insn->segmentOverride = SEG_OVERRIDE_ES; + if (insn->mode != MODE_64BIT) { + insn->segmentOverride = SEG_OVERRIDE_ES; + } insn->prefix1 = byte; break; case 0x64: From 0cf6d87890ae49f21bb69aaa83bb08e06bfd61b8 Mon Sep 17 00:00:00 2001 From: Jos Date: Tue, 9 Dec 2025 16:26:30 +0100 Subject: [PATCH 2/5] Add tests for x86 segment override prefixes --- tests/issues/x86-prefixes.yaml | 217 +++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 tests/issues/x86-prefixes.yaml diff --git a/tests/issues/x86-prefixes.yaml b/tests/issues/x86-prefixes.yaml new file mode 100644 index 0000000000..4c80292529 --- /dev/null +++ b/tests/issues/x86-prefixes.yaml @@ -0,0 +1,217 @@ +test_cases: + # Test segment override priority + - + input: + name: "x86-16: rightmost segment override should take priority" + bytes: [ 0x26, 0x65, 0x64, 0x3E, 0x65, 0x2E, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_16 ] + expected: + insns: + - + asm_text: "add byte ptr cs:[bx + si], al" + - + input: + name: "x86-32: rightmost segment override should take priority" + bytes: [ 0x26, 0x65, 0x64, 0x3E, 0x65, 0x2E, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_32 ] + expected: + insns: + - + asm_text: "add byte ptr cs:[eax], al" + - + input: + name: "x86-64: rightmost segment override should take priority" + bytes: [ 0x26, 0x65, 0x64, 0x3E, 0x65, 0x2E, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_64 ] + expected: + insns: + - + asm_text: "add byte ptr gs:[rax], al" + - + input: + name: "x86-16: rightmost segment override should take priority" + bytes: [ 0x3E, 0x3E, 0x26, 0x36, 0x64, 0x36, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_16 ] + expected: + insns: + - + asm_text: "add byte ptr ss:[bx + si], al" + - + input: + name: "x86-32: rightmost segment override should take priority" + bytes: [ 0x3E, 0x3E, 0x26, 0x36, 0x64, 0x36, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_32 ] + expected: + insns: + - + asm_text: "add byte ptr ss:[eax], al" + - + input: + name: "x86-64: rightmost segment override should take priority" + bytes: [ 0x3E, 0x3E, 0x26, 0x36, 0x64, 0x36, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_64 ] + expected: + insns: + - + asm_text: "add byte ptr fs:[rax], al" + # Test segment override differences between 16/32 and 64-bit mode with ECDS and FS/GS + - + input: + name: "x86-16: ECSD segment overrides should override FS/GS segment overrides" + bytes: [ 0x64, 0x3E, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_16 ] + expected: + insns: + - + asm_text: "add byte ptr ds:[bx + si], al" + - + input: + name: "x86-32: ECSD segment overrides should override FS/GS segment overrides" + bytes: [ 0x64, 0x3E, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_32 ] + expected: + insns: + - + asm_text: "add byte ptr ds:[eax], al" + - + input: + name: "x86-64: ECSD segment overrides should be ignored and leave FS override intact" + bytes: [ 0x64, 0x3E, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_64 ] + expected: + insns: + - + asm_text: "add byte ptr fs:[rax], al" + - + input: + name: "x86-64: ECSD segment overrides should be ignored" + bytes: [ 0x3E, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_64 ] + expected: + insns: + - + asm_text: "add byte ptr [rax], al" + # Test duplicate segment override prefixes + - + input: + name: "x86-16: Duplicate ES override prefixes should decode successfully" + bytes: [ 0x26, 0x26, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_16 ] + expected: + insns: + - + asm_text: "add byte ptr es:[bx + si], al" + - + input: + name: "x86-32: Duplicate ES override prefixes should decode successfully" + bytes: [ 0x26, 0x26, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_32 ] + expected: + insns: + - + asm_text: "add byte ptr es:[eax], al" + - + input: + name: "x86-64: Duplicate FS override prefixes should decode successfully" + bytes: [ 0x64, 0x64, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_64 ] + expected: + insns: + - + asm_text: "add byte ptr fs:[rax], al" + # Test invalid REX prefix + - + input: + name: "x86-64: Invalid REX prefix should preserve previous segment override" + bytes: [ 0x64, 0x40, 0x2E, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_64 ] + expected: + insns: + - + asm_text: "add byte ptr fs:[rax], al" + - + input: + name: "x86-64: Invalid REX prefix should not add ECDS segment override" + bytes: [ 0x2E, 0x40, 0x2E, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_64 ] + expected: + insns: + - + asm_text: "add byte ptr [rax], al" + # Test whether `notrack` is correctly decoded + - + input: + name: "x86-16: notrack should decode correctly" + bytes: [ 0x3E, 0xE8, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_16 ] + expected: + insns: + - + asm_text: "notrack call 4" + - + input: + name: "x86-32: notrack should decode correctly" + bytes: [ 0x3E, 0xE8, 0x00, 0x00, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_32 ] + expected: + insns: + - + asm_text: "notrack call 6" + - + input: + name: "x86-64: notrack should decode correctly" + bytes: [ 0x3E, 0xE8, 0x00, 0x00, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_64 ] + expected: + insns: + - + asm_text: "notrack call 6" + + - + input: + name: "x86-16: notrack should be applied when 0x3E is last segment override prefix" + bytes: [ 0x26, 0x64, 0x3E, 0xE8, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_16 ] + expected: + insns: + - + asm_text: "notrack call 6" + - + input: + name: "x86-32: notrack should be applied when 0x3E is last segment override prefix" + bytes: [ 0x26, 0x64, 0x3E, 0xE8, 0x00, 0x00, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_32 ] + expected: + insns: + - + asm_text: "notrack call 8" + - + input: + name: "x86-64: notrack should be applied when 0x3E is last segment override prefix" + bytes: [ 0x26, 0x64, 0x3E, 0xE8, 0x00, 0x00, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_MODE_64 ] + expected: + insns: + - + asm_text: "notrack call 8" \ No newline at end of file From 187d10446d091eefbe8d38dad577a0938ea37ae4 Mon Sep 17 00:00:00 2001 From: Jos Date: Tue, 6 Jan 2026 18:22:23 +0100 Subject: [PATCH 3/5] Only update prefix1 if needed --- arch/X86/X86DisassemblerDecoder.c | 36 ++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/arch/X86/X86DisassemblerDecoder.c b/arch/X86/X86DisassemblerDecoder.c index 3b141036f3..6daf4862c4 100644 --- a/arch/X86/X86DisassemblerDecoder.c +++ b/arch/X86/X86DisassemblerDecoder.c @@ -523,28 +523,40 @@ static int readPrefixes(struct InternalInstruction *insn) case 0x65: /* GS segment override */ switch (byte) { case 0x2e: - if (insn->mode != MODE_64BIT) { - insn->segmentOverride = SEG_OVERRIDE_CS; + if (insn->mode != MODE_64BIT || (insn->prefix1 != 0x64 && insn->prefix1 != 0x65)) { + if (insn->mode != MODE_64BIT) { + insn->segmentOverride = SEG_OVERRIDE_CS; + } + + insn->prefix1 = byte; } - insn->prefix1 = byte; break; case 0x36: - if (insn->mode != MODE_64BIT) { - insn->segmentOverride = SEG_OVERRIDE_SS; + if (insn->mode != MODE_64BIT || (insn->prefix1 != 0x64 && insn->prefix1 != 0x65)) { + if (insn->mode != MODE_64BIT) { + insn->segmentOverride = SEG_OVERRIDE_SS; + } + + insn->prefix1 = byte; } - insn->prefix1 = byte; break; case 0x3e: - if (insn->mode != MODE_64BIT) { - insn->segmentOverride = SEG_OVERRIDE_DS; + if (insn->mode != MODE_64BIT || (insn->prefix1 != 0x64 && insn->prefix1 != 0x65)) { + if (insn->mode != MODE_64BIT) { + insn->segmentOverride = SEG_OVERRIDE_DS; + } + + insn->prefix1 = byte; } - insn->prefix1 = byte; break; case 0x26: - if (insn->mode != MODE_64BIT) { - insn->segmentOverride = SEG_OVERRIDE_ES; + if (insn->mode != MODE_64BIT || (insn->prefix1 != 0x64 && insn->prefix1 != 0x65)) { + if (insn->mode != MODE_64BIT) { + insn->segmentOverride = SEG_OVERRIDE_ES; + } + + insn->prefix1 = byte; } - insn->prefix1 = byte; break; case 0x64: insn->segmentOverride = SEG_OVERRIDE_FS; From e84be54c77873f96b31b43931e6c0aacae121462 Mon Sep 17 00:00:00 2001 From: Jos Date: Tue, 6 Jan 2026 18:22:48 +0100 Subject: [PATCH 4/5] Also check prefix details in tests --- tests/issues/x86-prefixes.yaml | 122 ++++++++++++++++++++++++++------- 1 file changed, 99 insertions(+), 23 deletions(-) diff --git a/tests/issues/x86-prefixes.yaml b/tests/issues/x86-prefixes.yaml index 4c80292529..2731d02beb 100644 --- a/tests/issues/x86-prefixes.yaml +++ b/tests/issues/x86-prefixes.yaml @@ -5,213 +5,289 @@ test_cases: name: "x86-16: rightmost segment override should take priority" bytes: [ 0x26, 0x65, 0x64, 0x3E, 0x65, 0x2E, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_16 ] + options: [ CS_OPT_DETAIL, CS_MODE_16 ] expected: insns: - asm_text: "add byte ptr cs:[bx + si], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_CS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-32: rightmost segment override should take priority" bytes: [ 0x26, 0x65, 0x64, 0x3E, 0x65, 0x2E, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_32 ] + options: [ CS_OPT_DETAIL, CS_MODE_32 ] expected: insns: - asm_text: "add byte ptr cs:[eax], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_CS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-64: rightmost segment override should take priority" bytes: [ 0x26, 0x65, 0x64, 0x3E, 0x65, 0x2E, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_64 ] + options: [ CS_OPT_DETAIL, CS_MODE_64 ] expected: insns: - asm_text: "add byte ptr gs:[rax], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_GS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-16: rightmost segment override should take priority" bytes: [ 0x3E, 0x3E, 0x26, 0x36, 0x64, 0x36, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_16 ] + options: [ CS_OPT_DETAIL, CS_MODE_16 ] expected: insns: - asm_text: "add byte ptr ss:[bx + si], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_SS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-32: rightmost segment override should take priority" bytes: [ 0x3E, 0x3E, 0x26, 0x36, 0x64, 0x36, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_32 ] + options: [ CS_OPT_DETAIL, CS_MODE_32 ] expected: insns: - asm_text: "add byte ptr ss:[eax], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_SS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-64: rightmost segment override should take priority" bytes: [ 0x3E, 0x3E, 0x26, 0x36, 0x64, 0x36, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_64 ] + options: [ CS_OPT_DETAIL, CS_MODE_64 ] expected: insns: - asm_text: "add byte ptr fs:[rax], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_FS, X86_PREFIX_0, X86_PREFIX_0 ] # Test segment override differences between 16/32 and 64-bit mode with ECDS and FS/GS - input: name: "x86-16: ECSD segment overrides should override FS/GS segment overrides" bytes: [ 0x64, 0x3E, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_16 ] + options: [ CS_OPT_DETAIL, CS_MODE_16 ] expected: insns: - asm_text: "add byte ptr ds:[bx + si], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_DS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-32: ECSD segment overrides should override FS/GS segment overrides" bytes: [ 0x64, 0x3E, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_32 ] + options: [ CS_OPT_DETAIL, CS_MODE_32 ] expected: insns: - asm_text: "add byte ptr ds:[eax], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_DS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-64: ECSD segment overrides should be ignored and leave FS override intact" bytes: [ 0x64, 0x3E, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_64 ] + options: [ CS_OPT_DETAIL, CS_MODE_64 ] expected: insns: - asm_text: "add byte ptr fs:[rax], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_FS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-64: ECSD segment overrides should be ignored" bytes: [ 0x3E, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_64 ] + options: [ CS_OPT_DETAIL, CS_MODE_64 ] expected: insns: - asm_text: "add byte ptr [rax], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_DS, X86_PREFIX_0, X86_PREFIX_0 ] # Test duplicate segment override prefixes - input: name: "x86-16: Duplicate ES override prefixes should decode successfully" bytes: [ 0x26, 0x26, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_16 ] + options: [ CS_OPT_DETAIL, CS_MODE_16 ] expected: insns: - asm_text: "add byte ptr es:[bx + si], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_ES, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-32: Duplicate ES override prefixes should decode successfully" bytes: [ 0x26, 0x26, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_32 ] + options: [ CS_OPT_DETAIL, CS_MODE_32 ] expected: insns: - asm_text: "add byte ptr es:[eax], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_ES, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-64: Duplicate FS override prefixes should decode successfully" bytes: [ 0x64, 0x64, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_64 ] + options: [ CS_OPT_DETAIL, CS_MODE_64 ] expected: insns: - asm_text: "add byte ptr fs:[rax], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_FS, X86_PREFIX_0, X86_PREFIX_0 ] # Test invalid REX prefix - input: name: "x86-64: Invalid REX prefix should preserve previous segment override" bytes: [ 0x64, 0x40, 0x2E, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_64 ] + options: [ CS_OPT_DETAIL, CS_MODE_64 ] expected: insns: - asm_text: "add byte ptr fs:[rax], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_FS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-64: Invalid REX prefix should not add ECDS segment override" bytes: [ 0x2E, 0x40, 0x2E, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_64 ] + options: [ CS_OPT_DETAIL, CS_MODE_64 ] expected: insns: - asm_text: "add byte ptr [rax], al" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_CS, X86_PREFIX_0, X86_PREFIX_0 ] # Test whether `notrack` is correctly decoded - input: name: "x86-16: notrack should decode correctly" bytes: [ 0x3E, 0xE8, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_16 ] + options: [ CS_OPT_DETAIL, CS_MODE_16 ] expected: insns: - asm_text: "notrack call 4" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_DS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-32: notrack should decode correctly" bytes: [ 0x3E, 0xE8, 0x00, 0x00, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_32 ] + options: [ CS_OPT_DETAIL, CS_MODE_32 ] expected: insns: - asm_text: "notrack call 6" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_DS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-64: notrack should decode correctly" bytes: [ 0x3E, 0xE8, 0x00, 0x00, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_64 ] + options: [ CS_OPT_DETAIL, CS_MODE_64 ] expected: insns: - asm_text: "notrack call 6" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_DS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-16: notrack should be applied when 0x3E is last segment override prefix" bytes: [ 0x26, 0x64, 0x3E, 0xE8, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_16 ] + options: [ CS_OPT_DETAIL, CS_MODE_16 ] expected: insns: - asm_text: "notrack call 6" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_DS, X86_PREFIX_0, X86_PREFIX_0 ] - input: name: "x86-32: notrack should be applied when 0x3E is last segment override prefix" bytes: [ 0x26, 0x64, 0x3E, 0xE8, 0x00, 0x00, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_32 ] + options: [ CS_OPT_DETAIL, CS_MODE_32 ] expected: insns: - asm_text: "notrack call 8" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_DS, X86_PREFIX_0, X86_PREFIX_0 ] - input: - name: "x86-64: notrack should be applied when 0x3E is last segment override prefix" + name: "x86-64: workaround: notrack should only be applied when 0x3E is last segment override prefix and no FS/GS segment override prefix is active" bytes: [ 0x26, 0x64, 0x3E, 0xE8, 0x00, 0x00, 0x00, 0x00 ] arch: "CS_ARCH_X86" - options: [ CS_MODE_64 ] + options: [ CS_OPT_DETAIL, CS_MODE_64 ] expected: insns: - - asm_text: "notrack call 8" \ No newline at end of file + asm_text: "call 8" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_FS, X86_PREFIX_0, X86_PREFIX_0 ] + - + input: + name: "x86-64: workaround: notrack should only be applied when 0x3E is last segment override prefix and no FS/GS segment override prefix is active" + bytes: [ 0x26, 0x2E, 0x3E, 0xE8, 0x00, 0x00, 0x00, 0x00 ] + arch: "CS_ARCH_X86" + options: [ CS_OPT_DETAIL, CS_MODE_64 ] + expected: + insns: + - + asm_text: "notrack call 8" + details: + x86: + prefix: [ X86_PREFIX_0, X86_PREFIX_DS, X86_PREFIX_0, X86_PREFIX_0 ] \ No newline at end of file From 1e8c11b05f577c605c5bc5a9b489aa744dd32f47 Mon Sep 17 00:00:00 2001 From: Jos Date: Tue, 6 Jan 2026 18:48:05 +0100 Subject: [PATCH 5/5] Fix formatting --- arch/X86/X86DisassemblerDecoder.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/arch/X86/X86DisassemblerDecoder.c b/arch/X86/X86DisassemblerDecoder.c index 6daf4862c4..e915fb9e24 100644 --- a/arch/X86/X86DisassemblerDecoder.c +++ b/arch/X86/X86DisassemblerDecoder.c @@ -523,38 +523,50 @@ static int readPrefixes(struct InternalInstruction *insn) case 0x65: /* GS segment override */ switch (byte) { case 0x2e: - if (insn->mode != MODE_64BIT || (insn->prefix1 != 0x64 && insn->prefix1 != 0x65)) { + if (insn->mode != MODE_64BIT || + (insn->prefix1 != 0x64 && + insn->prefix1 != 0x65)) { if (insn->mode != MODE_64BIT) { - insn->segmentOverride = SEG_OVERRIDE_CS; + insn->segmentOverride = + SEG_OVERRIDE_CS; } insn->prefix1 = byte; } break; case 0x36: - if (insn->mode != MODE_64BIT || (insn->prefix1 != 0x64 && insn->prefix1 != 0x65)) { + if (insn->mode != MODE_64BIT || + (insn->prefix1 != 0x64 && + insn->prefix1 != 0x65)) { if (insn->mode != MODE_64BIT) { - insn->segmentOverride = SEG_OVERRIDE_SS; + insn->segmentOverride = + SEG_OVERRIDE_SS; } insn->prefix1 = byte; } break; case 0x3e: - if (insn->mode != MODE_64BIT || (insn->prefix1 != 0x64 && insn->prefix1 != 0x65)) { + if (insn->mode != MODE_64BIT || + (insn->prefix1 != 0x64 && + insn->prefix1 != 0x65)) { if (insn->mode != MODE_64BIT) { - insn->segmentOverride = SEG_OVERRIDE_DS; + insn->segmentOverride = + SEG_OVERRIDE_DS; } insn->prefix1 = byte; } break; case 0x26: - if (insn->mode != MODE_64BIT || (insn->prefix1 != 0x64 && insn->prefix1 != 0x65)) { + if (insn->mode != MODE_64BIT || + (insn->prefix1 != 0x64 && + insn->prefix1 != 0x65)) { if (insn->mode != MODE_64BIT) { - insn->segmentOverride = SEG_OVERRIDE_ES; + insn->segmentOverride = + SEG_OVERRIDE_ES; } - + insn->prefix1 = byte; } break;