1 #include <common.h> 2 #include <debug.h> 3 #include <libelf.h> 4 #include <hash.h> 5 #include <string.h> 6 7 int hash_lookup(Elf *elf, 8 Elf_Data *hash, 9 Elf_Data *symtab, 10 Elf_Data *symstr, 11 const char *symname) { 12 Elf32_Word *hash_data = (Elf32_Word *)hash->d_buf; 13 Elf32_Word index; 14 Elf32_Word nbuckets = *hash_data++; 15 Elf32_Word *buckets = ++hash_data; 16 Elf32_Word *chains = hash_data + nbuckets; 17 18 index = buckets[elf_hash(symname) % nbuckets]; 19 while (index != STN_UNDEF && 20 strcmp((char *)symstr->d_buf + 21 ((Elf32_Sym *)symtab->d_buf)[index].st_name, 22 symname)) { 23 index = chains[index]; 24 } 25 26 return index; 27 } 28