This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Glitches in gas/objdump handling of i386 STR, SLDT, SMSW instructions
- To: Zack Weinberg <zack at codesourcery dot com>
- Subject: Re: Glitches in gas/objdump handling of i386 STR, SLDT, SMSW instructions
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Sun, 11 Nov 2001 16:31:29 -0800
- Cc: binutils at sources dot redhat dot com
- References: <20011111161911.A2608@codesourcery.com>
On Sun, Nov 11, 2001 at 04:19:11PM -0800, Zack Weinberg wrote:
> A comment on linux-kernel led me to discover some bugs in gas and
> objdump -d handling of the STR and SMSW instructions.
>
> First and most seriously: gas incorrectly thinks STR is invalid except
> with a 16-bit operand. In reality, STR works like most i386
> word/long/quad instructions: the operand size prefixes apply. To
> demonstrate this, compile and run this test program:
...
> The same bug applies to the SLDT and SMSW instructions, although GAS
> gets them right.
>
> I believe this is an appropriate patch. I've run test files
> containing STR, SMSW, and SLDT instructions through the resultant as
> and objdump, but I haven't done a full build+test cycle. Nor have I
> checked the rest of the segment instructions thoroughly.
>
> zw
>
> * include/opcode/i386.h: Change "str" instruction to
> wlq_Suf|Modrm, WordReg|WordMem.
> * opcodes/i386-dis.c: Change "sldt", "str", and "smsw" entries
> to "sldtQ", "strQ", "smswQ" respectively; all with Ev operand
> category instead of Ew.
>
> ===================================================================
> Index: include/opcode/i386.h
> --- include/opcode/i386.h 2001/05/12 09:52:39 1.33
> +++ include/opcode/i386.h 2001/11/12 00:11:42
> @@ -555,7 +555,7 @@ static const template i386_optab[] = {
> {"sidt", 1, 0x0f01, 1, Cpu286, wlq_Suf|Modrm, { WordMem, 0, 0} },
> {"sldt", 1, 0x0f00, 0, Cpu286, wlq_Suf|Modrm, { WordReg|WordMem, 0, 0} },
> {"smsw", 1, 0x0f01, 4, Cpu286, wlq_Suf|Modrm, { WordReg|WordMem, 0, 0} },
> -{"str", 1, 0x0f00, 1, Cpu286, w_Suf|Modrm|IgnoreSize,{ Reg16|ShortMem, 0, 0} },
> +{"str", 1, 0x0f00, 1, Cpu286, wlq_Suf|Modrm, { WordReg|WordMem, 0, 0} },
>
I don't think it is right. "str" takes a 16bit reg/mem or 32bit reg,
according to Intel ia32 manual.
H.J.