This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: Fix i386 disassembler with index == 0x4 in SIB (Re: objdump bug-report)
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: "H. J. Lu" <hjl at lucon dot org>
- Cc: "Allan B. Cruse" <cruse at cs dot usfca dot edu>,binutils at sources dot redhat dot com
- Date: Thu, 13 Jan 2005 14:14:40 +1030
- Subject: Re: PATCH: Fix i386 disassembler with index == 0x4 in SIB (Re: objdump bug-report)
- References: <20050111210753.0C8CB219E0@nexus.cs.usfca.edu> <20050112191052.GA12463@lucon.org>
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