The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 | { |
| 13 | Elf32_Word *hash_data = (Elf32_Word *)hash->d_buf; |
| 14 | Elf32_Word index; |
| 15 | Elf32_Word nbuckets = *hash_data++; |
| 16 | Elf32_Word *buckets = ++hash_data; |
| 17 | Elf32_Word *chains = hash_data + nbuckets; |
| 18 | |
| 19 | index = buckets[elf_hash(symname) % nbuckets]; |
| 20 | while(index != STN_UNDEF && |
| 21 | strcmp((char *)symstr->d_buf + |
| 22 | ((Elf32_Sym *)symtab->d_buf)[index].st_name, |
| 23 | symname)) |
| 24 | { |
| 25 | index = chains[index]; |
| 26 | } |
| 27 | |
| 28 | return index; |
| 29 | } |