PATCH: Fix i386 disassembler with index == 0x4 in SIB (Re: objdump bug-report)
Alan Modra
amodra@bigpond.net.au
Thu Jan 13 03:44:00 GMT 2005
On Wed, Jan 12, 2005 at 11:10:52AM -0800, H. J. Lu wrote:
> > .byte 0x8B, 0x04, 0x63 # effect is: movl (%ebx), %eax
[snip]
> > 8048081: 8b 04 63 mov (%ebx,2),%eax
I don't agree that this is a problem. In fact, I think that this
disassembly is more accurate than "mov (%ebx),%eax". Note that gas
accepts "mov (%ebx,2),%eax" giving
Warning: scale factor of 2 without an index register
Yes, I agree that the effect of executing these byte sequences is the
same as "mov (%ebx),%eax", but that's beside the point. For example,
plenty of x86 instructions execute as a nop, but that doesn't mean they
should all be disassembled as "nop". The disassembler ought to reflect
the machine encoding as closely as possible, and in this case that means
printing the ignored scale factor.
I think this change should be reverted.
> --- binutils/opcodes/i386-dis.c.sib 2004-11-04 09:35:19.000000000 -0800
> +++ binutils/opcodes/i386-dis.c 2005-01-12 10:50:01.790879515 -0800
> @@ -3191,8 +3191,10 @@ OP_E (int bytemode, int sizeflag)
> {
> havesib = 1;
> FETCH_DATA (the_info, codep + 1);
> - scale = (*codep >> 6) & 3;
> index = (*codep >> 3) & 7;
> + if (index != 0x4)
> + /* When INDEX == 0x4, scale is ignored. */
> + scale = (*codep >> 6) & 3;
> base = *codep & 7;
> USED_REX (REX_EXTY);
> USED_REX (REX_EXTZ);
--
Alan Modra
IBM OzLabs - Linux Technology Centre
More information about the Binutils
mailing list