public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: x86: correct decoding of nop/reserved space (0f18 ... 0x1f)
@ 2021-03-12  0:45 Alan Modra
  2021-03-12  7:11 ` Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Modra @ 2021-03-12  0:45 UTC (permalink / raw)
  To: binutils

When assembling this testcase then disassembling
 .byte 0x66, 0xf2, 0x0f, 0x1c, 0x20
asan reports
i386-dis.c:9786:14: runtime error: index -1 out of bounds for type 'int [14]'

	* i386-dis.c (print_insn <PREFIX_IGNORED>): Correct typo.

diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 2985e8d441..4e3304d4a4 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -9783,7 +9783,7 @@ print_insn (bfd_vma pc, disassemble_info *info)
 	 origins in all_prefixes.  */
       used_prefixes &= ~PREFIX_OPCODE;
       if (last_data_prefix >= 0)
-	all_prefixes[last_repz_prefix] = 0x66;
+	all_prefixes[last_data_prefix] = 0x66;
       if (last_repz_prefix >= 0)
 	all_prefixes[last_repz_prefix] = 0xf3;
       if (last_repnz_prefix >= 0)

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: x86: correct decoding of nop/reserved space (0f18 ... 0x1f)
  2021-03-12  0:45 x86: correct decoding of nop/reserved space (0f18 ... 0x1f) Alan Modra
@ 2021-03-12  7:11 ` Jan Beulich
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2021-03-12  7:11 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

On 12.03.2021 01:45, Alan Modra wrote:
> When assembling this testcase then disassembling
>  .byte 0x66, 0xf2, 0x0f, 0x1c, 0x20
> asan reports
> i386-dis.c:9786:14: runtime error: index -1 out of bounds for type 'int [14]'
> 
> 	* i386-dis.c (print_insn <PREFIX_IGNORED>): Correct typo.
> 
> diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
> index 2985e8d441..4e3304d4a4 100644
> --- a/opcodes/i386-dis.c
> +++ b/opcodes/i386-dis.c
> @@ -9783,7 +9783,7 @@ print_insn (bfd_vma pc, disassemble_info *info)
>  	 origins in all_prefixes.  */
>        used_prefixes &= ~PREFIX_OPCODE;
>        if (last_data_prefix >= 0)
> -	all_prefixes[last_repz_prefix] = 0x66;
> +	all_prefixes[last_data_prefix] = 0x66;
>        if (last_repz_prefix >= 0)
>  	all_prefixes[last_repz_prefix] = 0xf3;
>        if (last_repnz_prefix >= 0)

Urgh - what a bad copy-and-paste mistake. Thanks for spotting/fixing.
I wonder why this didn't break one of the test cases.

Jan


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-12  7:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12  0:45 x86: correct decoding of nop/reserved space (0f18 ... 0x1f) Alan Modra
2021-03-12  7:11 ` Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).