Index: rtld.h =================================================================== RCS file: /cvsroot/src/libexec/ld.elf_so/rtld.h,v retrieving revision 1.144 diff -u -p -u -r1.144 rtld.h --- rtld.h 21 Jun 2022 06:52:17 -0000 1.144 +++ rtld.h 18 Apr 2023 15:15:47 -0000 @@ -440,8 +440,8 @@ void _rtld_call_ifunc(Obj_Entry *, sigse Obj_Entry *_rtld_load_library(const char *, const Obj_Entry *, int); /* symbol.c */ -unsigned long _rtld_sysv_hash(const char *); -unsigned long _rtld_gnu_hash(const char *); +Elf32_Word _rtld_sysv_hash(const char *); +Elf32_Word _rtld_gnu_hash(const char *); const Elf_Sym *_rtld_symlook_obj(const char *, Elf_Hash *, const Obj_Entry *, u_int, const Ver_Entry *); const Elf_Sym *_rtld_find_symdef(unsigned long, const Obj_Entry *, Index: symbol.c =================================================================== RCS file: /cvsroot/src/libexec/ld.elf_so/symbol.c,v retrieving revision 1.73 diff -u -p -u -r1.73 symbol.c --- symbol.c 29 Feb 2020 18:45:20 -0000 1.73 +++ symbol.c 18 Apr 2023 15:15:47 -0000 @@ -81,33 +81,27 @@ _rtld_donelist_check(DoneList *dlp, cons } /* - * 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 a slightly optimized + * version of the hash specified by the System V ABI. */ -unsigned long +Elf32_Word _rtld_sysv_hash(const char *name) { const unsigned char *p = (const unsigned char *) name; - unsigned long h = 0; - unsigned long g; - unsigned long c; - - for (; __predict_true((c = *p) != '\0'); p++) { - h <<= 4; - h += c; - if ((g = h & 0xf0000000) != 0) { - h ^= g; - h ^= g >> 24; - } + Elf32_Word h = 0; + + while (__predict_true(*p != '\0')) { + h = (h << 4) + *p++; + h ^= (h >> 24) & 0xf0; } - return (h); + return (h & 0xffffffff); } /* * Hash function for symbol table lookup. Don't even think about changing * this. It is specified by the GNU toolchain ABI. */ -unsigned long +Elf32_Word _rtld_gnu_hash(const char *name) { const unsigned char *p = (const unsigned char *) name; @@ -116,7 +110,7 @@ _rtld_gnu_hash(const char *name) for (c = *p; c != '\0'; c = *++p) h = h * 33 + c; - return (unsigned long)h; + return (h & 0xffffffff); } const Elf_Sym *