summaryrefslogtreecommitdiff
path: root/src/ldso/dynlink.c
diff options
context:
space:
mode:
authorAlexander Monakov <amonakov@ispras.ru>2015-06-28 02:48:32 +0300
committerRich Felker <dalias@aerifal.cx>2015-06-28 01:51:15 +0000
commit5b4286e12cd6baac343b10a41dc17ac578832089 (patch)
treee6741b056a2a89d2e5e8f58b23abe254e2965e6f /src/ldso/dynlink.c
parent84389c64562e2b2ba43225b5b7a9df7d974479b1 (diff)
downloadmusl-5b4286e12cd6baac343b10a41dc17ac578832089.tar.gz
musl-5b4286e12cd6baac343b10a41dc17ac578832089.tar.bz2
musl-5b4286e12cd6baac343b10a41dc17ac578832089.tar.xz
musl-5b4286e12cd6baac343b10a41dc17ac578832089.zip
dynlink.c: slim down gnu_lookup
Do not reference dso->syms and dso->strings until point of use. Check 'h1 == (h2|1)', the simplest condition, before the others.
Diffstat (limited to 'src/ldso/dynlink.c')
-rw-r--r--src/ldso/dynlink.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 4e6a5c83..bddafeb3 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -176,24 +176,20 @@ static Sym *sysv_lookup(const char *s, uint32_t h, struct dso *dso)
static Sym *gnu_lookup(const char *s, uint32_t h1, struct dso *dso)
{
- Sym *syms = dso->syms;
- char *strings = dso->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 i = buckets[h1 % nbuckets];
if (!i) return 0;
- hashval = buckets + nbuckets + (i - hashtab[1]);
+ uint32_t *hashval = buckets + nbuckets + (i - hashtab[1]);
for (h1 |= 1; ; i++) {
- h2 = *hashval++;
- if ((!dso->versym || dso->versym[i] >= 0)
- && (h1 == (h2|1)) && !strcmp(s, strings + syms[i].st_name))
- return syms+i;
+ uint32_t h2 = *hashval++;
+ if ((h1 == (h2|1)) && (!dso->versym || dso->versym[i] >= 0)
+ && !strcmp(s, dso->strings + dso->syms[i].st_name))
+ return dso->syms+i;
if (h2 & 1) break;
}