@@ -203,13 +203,11 @@ struct symbol *find_func_containing(struct section *sec, unsigned long offset)
203
203
204
204
struct symbol * find_symbol_by_name (struct elf * elf , const char * name )
205
205
{
206
- struct section * sec ;
207
206
struct symbol * sym ;
208
207
209
- list_for_each_entry (sec , & elf -> sections , list )
210
- list_for_each_entry (sym , & sec -> symbol_list , list )
211
- if (!strcmp (sym -> name , name ))
212
- return sym ;
208
+ hash_for_each_possible (elf -> symbol_name_hash , sym , name_hash , str_hash (name ))
209
+ if (!strcmp (sym -> name , name ))
210
+ return sym ;
213
211
214
212
return NULL ;
215
213
}
@@ -386,6 +384,7 @@ static int read_symbols(struct elf *elf)
386
384
entry = & sym -> sec -> symbol_list ;
387
385
list_add (& sym -> list , entry );
388
386
hash_add (elf -> symbol_hash , & sym -> hash , sym -> idx );
387
+ hash_add (elf -> symbol_name_hash , & sym -> name_hash , str_hash (sym -> name ));
389
388
}
390
389
391
390
if (stats )
@@ -524,6 +523,7 @@ struct elf *elf_read(const char *name, int flags)
524
523
memset (elf , 0 , sizeof (* elf ));
525
524
526
525
hash_init (elf -> symbol_hash );
526
+ hash_init (elf -> symbol_name_hash );
527
527
hash_init (elf -> section_hash );
528
528
hash_init (elf -> section_name_hash );
529
529
INIT_LIST_HEAD (& elf -> sections );
0 commit comments