From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5046 invoked by alias); 18 Dec 2010 09:47:19 -0000 Received: (qmail 5037 invoked by uid 22791); 18 Dec 2010 09:47:18 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-wy0-f169.google.com (HELO mail-wy0-f169.google.com) (74.125.82.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 18 Dec 2010 09:47:13 +0000 Received: by wyj26 with SMTP id 26so1545411wyj.0 for ; Sat, 18 Dec 2010 01:47:10 -0800 (PST) Received: by 10.227.144.9 with SMTP id x9mr1179876wbu.103.1292665630802; Sat, 18 Dec 2010 01:47:10 -0800 (PST) Received: from localhost (rsandifo.gotadsl.co.uk [82.133.89.107]) by mx.google.com with ESMTPS id q18sm963871wbe.5.2010.12.18.01.47.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 18 Dec 2010 01:47:09 -0800 (PST) From: Richard Sandiford To: "Fu\, Chao-Ying" Mail-Followup-To: "Fu\, Chao-Ying" ,"Maciej W. Rozycki" , "Garbacea\, Ilie" , Joseph Myers , "binutils\@sourceware.org" , "Fuhler\, Rich" , "Lau\, David" , "Mills\, Kevin" , Catherine Moore , Nathan Sidwell , Nathan Froyd , rdsandiford@googlemail.com Cc: "Maciej W. Rozycki" , "Garbacea\, Ilie" , Joseph Myers , "binutils\@sourceware.org" , "Fuhler\, Rich" , "Lau\, David" , "Mills\, Kevin" , Catherine Moore , Nathan Sidwell , Nathan Froyd Subject: Re: [PATCH] MIPS: microMIPS ASE support References: <87y6fa9u3t.fsf@firetop.home> <876302kqvu.fsf@firetop.home> <871v5n9m7e.fsf@firetop.home> <7C6479EB2BF52547AC332FD6034646DA3018F765@exchdb02.mips.com> Date: Sat, 18 Dec 2010 10:09:00 -0000 In-Reply-To: <7C6479EB2BF52547AC332FD6034646DA3018F765@exchdb02.mips.com> (Chao-Ying Fu's message of "Fri, 17 Dec 2010 19:55:44 +0000") Message-ID: <871v5fbeg9.fsf@firetop.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2010-12/txt/msg00536.txt.bz2 "Fu, Chao-Ying" writes: >> > > + /* Now adjust the global symbols defined in this section. */ >> > > + symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym) >> > > + - symtab_hdr->sh_info); >> > > + sym_hashes = start_hashes = elf_sym_hashes (abfd); >> > > + end_hashes = sym_hashes + symcount; >> > > + >> > > + for (; sym_hashes < end_hashes; sym_hashes++) >> > > + { >> > > + struct elf_link_hash_entry *sym_hash = *sym_hashes; >> > > + >> > > + if ((sym_hash->root.type == bfd_link_hash_defined >> > > + || sym_hash->root.type == bfd_link_hash_defweak) >> > > + && sym_hash->root.u.def.section == sec >> > > + && sym_hash->root.u.def.value > addr >> > > + && sym_hash->root.u.def.value < toaddr) >> > > + sym_hash->root.u.def.value -= count; >> > > + } >> > >> > ...if we're willing to extend the upper bound in this way, I wonder >> > whether there's really any point having an upper bound at all. >> > >> > Then again, why doesn't the standard range (used by most targets) >> > include toaddr? If you define an end marker: >> > >> > end_of_section: >> > # nothing after this >> > >> > then wouldn't end_of_section == toaddr, and shouldn't it be >> included? >> >> Ilie, I'm told you were responsible for this piece of code >> -- would you >> please respond to these questions? > > I think we should include "end_of_section == toaddr". > Ex: > && sym_hash->root.u.def.value <= toaddr) I agree that's probably the best thing, although I admit the "Then again," question was really more general musing than a question about this patch. To be more specific, the thing that worried me about this code was that: - if the section ends with a microMIPS instruction and an end marker, the "value < toaddr" won't include the end marker. (The end marker would be odd.) - if the section ends with a normal MIPS instruction and an end marker, the "value < toaddr" _would_ include the end marker. (The end marker would be even.) That's the key difference between "toaddr |= 1 ... value < toaddr" and "value &= -2 .... value < toaddr". I think the latter is more consistent. I suggest removing: + BFD_ASSERT (toaddr % 2 == 0); + addr |= 1; + toaddr |= 1; and instead masking the low bit off the u.def.value. (Keep the other two asserts though. I certainly found them useful when reviewing the code.) >> > > +static unsigned long >> > > +find_match (unsigned long opcode, const struct >> opcode_descriptor insn[]) >> > > +{ >> > > + unsigned long indx; >> > > + >> > > + /* First opcode_table[] entry is ignored. */ >> > > + for (indx = 1; insn[indx].mask != 0; indx++) >> > > + if (MATCH (opcode, insn[indx])) >> > > + return indx; >> > > + >> > > + return 0; >> > > +} >> > >> > But _why_ is the first entry ignored? >> >> There must be a reason, Ilie? > > I guess Ilie tries to avoid passing a single-entry table into find_match(). > But if we do pass a single-entry table into find_match(), > find_match() may not find the end marker and it will be wrong anyway. > Maybe we just delete all the { 1, 1 } entry in opcode_descriptor [] tables, and > find_match() doesn't ignore the first entry. > And we make sure that each table has end marker at the end. Yeah, I think that'd be better, thanks. Richard