From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26785 invoked by alias); 30 Jul 2012 17:04:11 -0000 Received: (qmail 26775 invoked by uid 22791); 30 Jul 2012 17:04:09 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-vc0-f169.google.com (HELO mail-vc0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 Jul 2012 17:03:45 +0000 Received: by vcbfl10 with SMTP id fl10so5532330vcb.0 for ; Mon, 30 Jul 2012 10:03:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.70.116 with SMTP id l20mr10441913vdu.19.1343667824971; Mon, 30 Jul 2012 10:03:44 -0700 (PDT) Received: by 10.58.179.79 with HTTP; Mon, 30 Jul 2012 10:03:44 -0700 (PDT) In-Reply-To: <500EDB2202000078000903AF@nat28.tlf.novell.com> References: <500EDB2202000078000903AF@nat28.tlf.novell.com> Date: Mon, 30 Jul 2012 17:04:00 -0000 Message-ID: Subject: Re: [PATCH] x86-64: correct segment override prefix generation From: "H.J. Lu" To: Jan Beulich Cc: binutils@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes 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/msg00295.txt.bz2 On Tue, Jul 24, 2012 at 8:28 AM, Jan Beulich wrote: > 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 = i.base_reg->reg_num; > /* x86-64 ignores REX prefix bit here to avoid decoder > complications. */ > - if ((i.base_reg->reg_num & 7) == EBP_REG_NUM) > - { > + if (!(i.base_reg->reg_flags & RegRex) > + && (i.base_reg->reg_num == EBP_REG_NUM > + || i.base_reg->reg_num == ESP_REG_NUM)) > default_seg = &ss; > - if (i.disp_operands == 0) > - { > - fake_zero_displacement = 1; > - i.types[op].bitfield.disp8 = 1; > - } > - } > - else if (i.base_reg->reg_num == ESP_REG_NUM) > + if (i.base_reg->reg_num == 5 && i.disp_operands == 0) > { > - default_seg = &ss; > + fake_zero_displacement = 1; > + i.types[op].bitfield.disp8 = 1; > } > i.sib.scale = i.log2_scale_factor; > if (i.index_reg == 0) > Please provide a testcase to show the correct behavior. Thanks. -- H.J.