Lines Matching full:elf
4 * Helper functions for finding the symbol in an ELF which is "nearest"
50 static unsigned int symbol_count(struct elf_info *elf) in symbol_count() argument
54 for (Elf_Sym *sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { in symbol_count()
55 if (is_valid_name(elf, sym)) in symbol_count()
63 * Be slightly paranoid here. The ELF file is mmap'd and could
68 static void symsearch_populate(struct elf_info *elf, in symsearch_populate() argument
72 bool is_arm = (elf->hdr->e_machine == EM_ARM); in symsearch_populate()
74 for (Elf_Sym *sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { in symsearch_populate()
75 if (is_valid_name(elf, sym)) { in symsearch_populate()
78 table->symbol_index = sym - elf->symtab_start; in symsearch_populate()
79 table->section_index = get_secindex(elf, sym); in symsearch_populate()
124 void symsearch_init(struct elf_info *elf) in symsearch_init() argument
126 unsigned int table_size = symbol_count(elf); in symsearch_init()
128 elf->symsearch = xmalloc(sizeof(struct symsearch) + in symsearch_init()
130 elf->symsearch->table_size = table_size; in symsearch_init()
132 symsearch_populate(elf, elf->symsearch->table, table_size); in symsearch_init()
133 qsort(elf->symsearch->table, table_size, in symsearch_init()
136 symsearch_fixup(elf->symsearch->table, table_size); in symsearch_init()
139 void symsearch_finish(struct elf_info *elf) in symsearch_finish() argument
141 free(elf->symsearch); in symsearch_finish()
142 elf->symsearch = NULL; in symsearch_finish()
153 Elf_Sym *symsearch_find_nearest(struct elf_info *elf, Elf_Addr addr, in symsearch_find_nearest() argument
157 unsigned int hi = elf->symsearch->table_size; in symsearch_find_nearest()
159 struct syminfo *table = elf->symsearch->table; in symsearch_find_nearest()
187 hi < elf->symsearch->table_size && in symsearch_find_nearest()
191 result = &elf->symtab_start[table[hi].symbol_index]; in symsearch_find_nearest()
196 result = &elf->symtab_start[table[hi - 1].symbol_index]; in symsearch_find_nearest()