From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1715 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: ldso : dladdr support Date: Fri, 24 Aug 2012 10:12:27 +0200 Message-ID: <20120824081227.GG10731@port70.net> References: <5022703B.3090105@gmail.com> <20120811230536.GQ27715@brightrain.aerifal.cx> <20120817053934.GS27715@brightrain.aerifal.cx> <50311776.9040802@gmail.com> <20120820020626.GD27715@brightrain.aerifal.cx> <503233A8.8000604@gmail.com> <50324A60.7040206@gmail.com> <20120823213937.GS27715@brightrain.aerifal.cx> <20120823222113.GT27715@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1345795960 13602 80.91.229.3 (24 Aug 2012 08:12:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 Aug 2012 08:12:40 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1716-gllmg-musl=m.gmane.org@lists.openwall.com Fri Aug 24 10:12:41 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1T4p0T-0001Bl-GF for gllmg-musl@plane.gmane.org; Fri, 24 Aug 2012 10:12:41 +0200 Original-Received: (qmail 13832 invoked by uid 550); 24 Aug 2012 08:12:39 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 13824 invoked from network); 24 Aug 2012 08:12:39 -0000 Content-Disposition: inline In-Reply-To: <20120823222113.GT27715@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:1715 Archived-At: * Rich Felker [2012-08-23 18:21:13 -0400]: > +static Sym *gnu_lookup(const char *s, uint32_t h1, struct dso *dso) > +{ > + Sym *sym; > + char *strings; > + uint32_t *hashtab = dso->ghashtab; > + uint32_t nbuckets = hashtab[0]; > + uint32_t *buckets = hashtab + 4 + hashtab[2]*(sizeof(size_t)/4); > + uint32_t h2; > + uint32_t *hashval; > + uint32_t n = buckets[h1 % nbuckets]; > + > + if (!n) return 0; > + > + strings = dso->strings; > + sym = dso->syms + n; > + hashval = buckets + nbuckets + (n - hashtab[1]); > + > + for (h1 |= 1; ; sym++) { > + h2 = *hashval++; > + if ((h1 == (h2|1)) && !strcmp(s, strings + sym->st_name)) > + return sym; > + if (h2 & 1) break; > + } heh, is this really the gnuhash lookup logic? they drop a valuable low bit with h1 |= 1 high bits are less important for short strings because of the *33 logic (last 3-4 chars have no effect on the msb) not that it matters much of course.. but seems silly design to me especially when nbuckets is a power-of-2, then highbits are not used for much and could be used as flags for whatever