From: whitequark Date: Sat, 1 Aug 2015 14:21:31 +0000 (+0300) Subject: libdyld: fix dyld_lookup algorithm. X-Git-Tag: 24jan2021_ls180~2164 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3f7f0a31512d233d1ae18a7c6d97faedbcb32145;p=litex.git libdyld: fix dyld_lookup algorithm. --- diff --git a/software/libdyld/dyld.c b/software/libdyld/dyld.c index 3b9cfe46..1b548f5d 100644 --- a/software/libdyld/dyld.c +++ b/software/libdyld/dyld.c @@ -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); }