From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9013 invoked by alias); 24 Jul 2012 15:28:20 -0000 Received: (qmail 9002 invoked by uid 22791); 24 Jul 2012 15:28:19 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from nat28.tlf.novell.com (HELO nat28.tlf.novell.com) (130.57.49.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Jul 2012 15:28:06 +0000 Received: from EMEA1-MTA by nat28.tlf.novell.com with Novell_GroupWise; Tue, 24 Jul 2012 16:28:04 +0100 Message-Id: <500EDB2202000078000903AF@nat28.tlf.novell.com> Date: Tue, 24 Jul 2012 15:28:00 -0000 From: "Jan Beulich" To: Subject: [PATCH] x86-64: correct segment override prefix generation Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part9BAAC812.0__=" Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2012-07/txt/msg00177.txt.bz2 This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part9BAAC812.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-length: 1429 Despite them being ignored by the CPU, gas issues segment override prefixes for other than FS/GS in 64-bit mode. If doing so at all, it should clearly do this correctly. Determining the default segment, however, requires to take into consideration RegRex (so far, RSP, RBP, R12, and R13 were all treated equally here). 2012-07-24 Jan Beulich * config/tc-i386-intel.c (build_modrm_byte): Split determining default segment from figuring out encoding. Honor RegRex for the former. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -5733,18 +5733,14 @@ build_modrm_byte (void) i.sib.base =3D i.base_reg->reg_num; /* x86-64 ignores REX prefix bit here to avoid decoder complications. */ - if ((i.base_reg->reg_num & 7) =3D=3D EBP_REG_NUM) - { + if (!(i.base_reg->reg_flags & RegRex) + && (i.base_reg->reg_num =3D=3D EBP_REG_NUM + || i.base_reg->reg_num =3D=3D ESP_REG_NUM)) default_seg =3D &ss; - if (i.disp_operands =3D=3D 0) - { - fake_zero_displacement =3D 1; - i.types[op].bitfield.disp8 =3D 1; - } - } - else if (i.base_reg->reg_num =3D=3D ESP_REG_NUM) + if (i.base_reg->reg_num =3D=3D 5 && i.disp_operands =3D=3D 0) { - default_seg =3D &ss; + fake_zero_displacement =3D 1; + i.types[op].bitfield.disp8 =3D 1; } i.sib.scale =3D i.log2_scale_factor; if (i.index_reg =3D=3D 0) --=__Part9BAAC812.0__= Content-Type: text/plain; name="binutils-mainline-x86_64-default-seg.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="binutils-mainline-x86_64-default-seg.patch" Content-length: 1426 Despite them being ignored by the CPU, gas issues segment override prefixes for other than FS/GS in 64-bit mode. If doing so at all, it should clearly do this correctly. Determining the default segment, however, requires to take into consideration RegRex (so far, RSP, RBP, R12, and R13 were all treated equally here). 2012-07-24 Jan Beulich * config/tc-i386-intel.c (build_modrm_byte): Split determining default segment from figuring out encoding. Honor RegRex for the former. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -5733,18 +5733,14 @@ build_modrm_byte (void) i.sib.base =3D i.base_reg->reg_num; /* x86-64 ignores REX prefix bit here to avoid decoder complications. */ - if ((i.base_reg->reg_num & 7) =3D=3D EBP_REG_NUM) - { + if (!(i.base_reg->reg_flags & RegRex) + && (i.base_reg->reg_num =3D=3D EBP_REG_NUM + || i.base_reg->reg_num =3D=3D ESP_REG_NUM)) default_seg =3D &ss; - if (i.disp_operands =3D=3D 0) - { - fake_zero_displacement =3D 1; - i.types[op].bitfield.disp8 =3D 1; - } - } - else if (i.base_reg->reg_num =3D=3D ESP_REG_NUM) + if (i.base_reg->reg_num =3D=3D 5 && i.disp_operands =3D=3D 0) { - default_seg =3D &ss; + fake_zero_displacement =3D 1; + i.types[op].bitfield.disp8 =3D 1; } i.sib.scale =3D i.log2_scale_factor; if (i.index_reg =3D=3D 0) --=__Part9BAAC812.0__=--