Skip to content

Commit

Permalink
libdyld: fix dyld_lookup algorithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Aug 1, 2015
1 parent d43e470 commit 3f7f0a3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions software/libdyld/dyld.c
Expand Up @@ -154,13 +154,11 @@ static unsigned long elf_hash(const unsigned char *name)
void *dyld_lookup(const char *symbol, struct dyld_info *info) {
unsigned hash = elf_hash((const unsigned char*) symbol);
unsigned index = info->hash.bucket[hash % info->hash.nbucket];
while(strcmp(&info->strtab[info->symtab[index].st_name], symbol) &&
info->hash.chain[index] != STN_UNDEF)
while(strcmp(&info->strtab[info->symtab[index].st_name], symbol)) {
if(index == STN_UNDEF)
return NULL;
index = info->hash.chain[index];

if(info->hash.chain[index] != STN_UNDEF) {
return (void*)(info->base + info->symtab[index].st_value);
} else {
return NULL;
}

return (void*)(info->base + info->symtab[index].st_value);
}

0 comments on commit 3f7f0a3

Please sign in to comment.