Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <503741C7.6070807@gmail.com>
Date: Fri, 24 Aug 2012 10:56:39 +0200
From: musl <b.brezillon.musl@...il.com>
To: musl@...ts.openwall.com
Subject: Re: ldso : dladdr support

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.