From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1716 Path: news.gmane.org!not-for-mail From: musl Newsgroups: gmane.linux.lib.musl.general Subject: Re: ldso : dladdr support Date: Fri, 24 Aug 2012 10:56:39 +0200 Message-ID: <503741C7.6070807@gmail.com> 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> <20120824081227.GG10731@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1345798615 2156 80.91.229.3 (24 Aug 2012 08:56:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 Aug 2012 08:56:55 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1717-gllmg-musl=m.gmane.org@lists.openwall.com Fri Aug 24 10:56:56 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 1T4phH-0004P8-6Z for gllmg-musl@plane.gmane.org; Fri, 24 Aug 2012 10:56:55 +0200 Original-Received: (qmail 5662 invoked by uid 550); 24 Aug 2012 08:56:53 -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 5654 invoked from network); 24 Aug 2012 08:56:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=f9LEQvV9nnpQDAVIYcvKbZ13ihvJ2T2WZKkYRQ2vgC4=; b=wWm6Sigo55dAoG0y7KVpdpK1YTnr74xmpSir/heQ0IGQrQcdyxtRW1q9OHs4fgO5Bo ONFxkFXQb1tDt0wtmQRf8zpopSXqsGNoBZuHj6N41yPB2sHsfTcz7AEvUh6E72vneRmH vQYhZlE4Fmy8jzJw0Hy+8QKUwPo6RhDf7yEJMG9CuVMuJoZrFgkNqQi4cICdS6JwJAIa bycuYITpSFTE4SodnaP0711JEBv++QrPTPEN6G/ae2OxghEeTgnXO5IZjNQzFNIV/r5n zm47NlmZHL7DRYPXeIqPVtAVmAwyOwEb//pqxn/yf9tZhPwB4I7W7SteZRUW5qF8j/1H tKLQ== User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0 In-Reply-To: <20120824081227.GG10731@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:1716 Archived-At: On 24/08/2012 10:12, Szabolcs Nagy wrote: > * 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 When h1 |= 1 is done the bucket index and first hashval have already been stored in n and hashval. Then h1 is only used in the (h1 == (h2 | 1)) comparison. > 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 >