diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index 5f0649d7540c..8e1495acee2b 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -1470,23 +1470,20 @@ relocate_file(elf_file_t ef) } /* - * Hash function for symbol table lookup. Don't even think about changing - * this. It is specified by the System V ABI. + * SysV hash function for symbol table lookup. It is specified by the + * System V ABI. */ -static unsigned long +static Elf32_Word elf_hash(const char *name) { - const unsigned char *p = (const unsigned char *) name; - unsigned long h = 0; - unsigned long g; + const unsigned char *p = (const unsigned char *)name; + Elf32_Word h = 0; while (*p != '\0') { h = (h << 4) + *p++; - if ((g = h & 0xf0000000) != 0) - h ^= g >> 24; - h &= ~g; + h ^= (h >> 24) & 0xf0; } - return (h); + return (h & 0x0fffffff); } static int @@ -1497,7 +1494,7 @@ link_elf_lookup_symbol1(linker_file_t lf, const char *name, c_linker_sym_t *sym, unsigned long symnum; const Elf_Sym* symp; const char *strp; - unsigned long hash; + Elf32_Word hash; /* If we don't have a hash, bail. */ if (ef->buckets == NULL || ef->nbuckets == 0) {