Lines Matching refs:sym

113 	struct symbol *sym;  in find_symbol_by_index()  local
115 elf_hash_for_each_possible(symbol, sym, hash, idx) { in find_symbol_by_index()
116 if (sym->idx == idx) in find_symbol_by_index()
117 return sym; in find_symbol_by_index()
181 struct symbol *sym; in find_symbol_by_name() local
183 elf_hash_for_each_possible(symbol_name, sym, name_hash, str_hash(name)) { in find_symbol_by_name()
184 if (!strcmp(sym->name, name)) in find_symbol_by_name()
185 return sym; in find_symbol_by_name()
312 static void elf_add_symbol(struct elf *elf, struct symbol *sym) in elf_add_symbol() argument
317 sym->type = GELF_ST_TYPE(sym->sym.st_info); in elf_add_symbol()
318 sym->bind = GELF_ST_BIND(sym->sym.st_info); in elf_add_symbol()
320 sym->offset = sym->sym.st_value; in elf_add_symbol()
321 sym->len = sym->sym.st_size; in elf_add_symbol()
323 rb_add(&sym->node, &sym->sec->symbol_tree, symbol_to_offset); in elf_add_symbol()
324 pnode = rb_prev(&sym->node); in elf_add_symbol()
328 entry = &sym->sec->symbol_list; in elf_add_symbol()
329 list_add(&sym->list, entry); in elf_add_symbol()
330 elf_hash_add(symbol, &sym->hash, sym->idx); in elf_add_symbol()
331 elf_hash_add(symbol_name, &sym->name_hash, str_hash(sym->name)); in elf_add_symbol()
337 if (!sym->len) in elf_add_symbol()
338 rb_erase(&sym->node, &sym->sec->symbol_tree); in elf_add_symbol()
344 struct symbol *sym, *pfunc; in read_symbols() local
372 sym = malloc(sizeof(*sym)); in read_symbols()
373 if (!sym) { in read_symbols()
377 memset(sym, 0, sizeof(*sym)); in read_symbols()
378 INIT_LIST_HEAD(&sym->pv_target); in read_symbols()
379 sym->alias = sym; in read_symbols()
381 sym->idx = i; in read_symbols()
383 if (!gelf_getsymshndx(symtab->data, shndx_data, i, &sym->sym, in read_symbols()
389 sym->name = elf_strptr(elf->elf, symtab->sh.sh_link, in read_symbols()
390 sym->sym.st_name); in read_symbols()
391 if (!sym->name) { in read_symbols()
396 if ((sym->sym.st_shndx > SHN_UNDEF && in read_symbols()
397 sym->sym.st_shndx < SHN_LORESERVE) || in read_symbols()
398 (shndx_data && sym->sym.st_shndx == SHN_XINDEX)) { in read_symbols()
399 if (sym->sym.st_shndx != SHN_XINDEX) in read_symbols()
400 shndx = sym->sym.st_shndx; in read_symbols()
402 sym->sec = find_section_by_index(elf, shndx); in read_symbols()
403 if (!sym->sec) { in read_symbols()
405 sym->name); in read_symbols()
408 if (GELF_ST_TYPE(sym->sym.st_info) == STT_SECTION) { in read_symbols()
409 sym->name = sym->sec->name; in read_symbols()
410 sym->sec->sym = sym; in read_symbols()
413 sym->sec = find_section_by_index(elf, 0); in read_symbols()
415 elf_add_symbol(elf, sym); in read_symbols()
425 list_for_each_entry(sym, &sec->symbol_list, list) { in read_symbols()
428 if (sym->type != STT_FUNC) in read_symbols()
431 if (sym->pfunc == NULL) in read_symbols()
432 sym->pfunc = sym; in read_symbols()
434 if (sym->cfunc == NULL) in read_symbols()
435 sym->cfunc = sym; in read_symbols()
437 coldstr = strstr(sym->name, ".cold"); in read_symbols()
441 pnamelen = coldstr - sym->name; in read_symbols()
444 sym->name, MAX_NAME_LEN); in read_symbols()
448 strncpy(pname, sym->name, pnamelen); in read_symbols()
454 sym->name); in read_symbols()
458 sym->pfunc = pfunc; in read_symbols()
459 pfunc->cfunc = sym; in read_symbols()
469 if (sym->sec == pfunc->sec && in read_symbols()
470 sym->offset >= pfunc->offset && in read_symbols()
471 sym->offset + sym->len == pfunc->offset + pfunc->len) { in read_symbols()
472 pfunc->len -= sym->len; in read_symbols()
480 free(sym); in read_symbols()
489 unsigned int type, struct symbol *sym, int addend) in elf_add_reloc() argument
506 reloc->sym = sym; in elf_add_reloc()
522 struct symbol *sym; in elf_add_reloc_to_insn() local
525 if (insn_sec->sym) { in elf_add_reloc_to_insn()
526 sym = insn_sec->sym; in elf_add_reloc_to_insn()
534 sym = find_symbol_containing(insn_sec, insn_off); in elf_add_reloc_to_insn()
535 if (!sym) { in elf_add_reloc_to_insn()
540 sym = find_symbol_containing(insn_sec, insn_off - 1); in elf_add_reloc_to_insn()
543 if (!sym) { in elf_add_reloc_to_insn()
548 addend = insn_off - sym->offset; in elf_add_reloc_to_insn()
551 return elf_add_reloc(elf, sec, offset, type, sym, addend); in elf_add_reloc_to_insn()
627 reloc->sym = find_symbol_by_index(elf, symndx); in read_relocs()
628 if (!reloc->sym) { in read_relocs()
918 reloc->rel.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); in elf_rebuild_rel_reloc_section()
950 reloc->rela.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); in elf_rebuild_rela_reloc_section()
994 reloc->rel.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); in elf_write_reloc()
1002 reloc->rela.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); in elf_write_reloc()
1063 struct symbol *sym, *tmpsym; in elf_close() local
1073 list_for_each_entry_safe(sym, tmpsym, &sec->symbol_list, list) { in elf_close()
1074 list_del(&sym->list); in elf_close()
1075 hash_del(&sym->hash); in elf_close()
1076 free(sym); in elf_close()