mailing list of musl libc
 help / color / mirror / code / Atom feed
From: musl <b.brezillon.musl@gmail.com>
To: musl@lists.openwall.com
Subject: Re: ldso : dladdr support
Date: Fri, 24 Aug 2012 10:56:39 +0200	[thread overview]
Message-ID: <503741C7.6070807@gmail.com> (raw)
In-Reply-To: <20120824081227.GG10731@port70.net>

On 24/08/2012 10:12, Szabolcs Nagy wrote:
> * Rich Felker <dalias@aerifal.cx> [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
>



  reply	other threads:[~2012-08-24  8:56 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-07  9:04 musl
2012-08-07 11:46 ` Szabolcs Nagy
2012-08-07 14:15   ` musl
2012-08-07 14:53     ` Szabolcs Nagy
2012-08-07 23:09     ` Rich Felker
2012-08-08  9:55       ` musl
2012-08-08 11:52         ` Szabolcs Nagy
2012-08-08 12:54           ` Rich Felker
2012-08-08 13:57           ` musl
2012-08-11 23:05             ` Rich Felker
2012-08-15 22:41               ` boris brezillon
2012-08-17  5:39                 ` Rich Felker
2012-08-19 16:42                   ` musl
2012-08-20  2:06                     ` Rich Felker
2012-08-20 12:55                       ` musl
2012-08-20 14:32                         ` musl
2012-08-23 21:39                           ` Rich Felker
2012-08-23 22:21                             ` Rich Felker
2012-08-24  7:29                               ` musl
2012-08-24 18:38                                 ` Rich Felker
2012-08-25  7:42                                   ` boris brezillon
2012-08-25 12:35                                     ` Rich Felker
2012-08-25 22:13                                   ` musl
2012-08-25 22:37                                     ` musl
2012-08-26  0:00                                   ` musl
2012-08-24  8:12                               ` Szabolcs Nagy
2012-08-24  8:56                                 ` musl [this message]
2012-08-24  9:38                                   ` Szabolcs Nagy
2012-08-25 21:34                               ` musl
2012-08-25 21:42                                 ` Rich Felker
2012-08-16 18:03               ` musl
2012-08-17 16:35               ` musl
2012-08-08 12:49         ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=503741C7.6070807@gmail.com \
    --to=b.brezillon.musl@gmail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).