Lines Matching refs:sym
109 const struct symbol *sym; member
125 sh->sym = s; in symbol_hole_by_offset()
159 struct symbol *sym; in find_symbol_by_index() local
161 elf_hash_for_each_possible(symbol, sym, hash, idx) { in find_symbol_by_index()
162 if (sym->idx == idx) in find_symbol_by_index()
163 return sym; in find_symbol_by_index()
215 .sym = NULL, in find_symbol_hole_containing()
230 if (!hole.sym) in find_symbol_hole_containing()
234 n = rb_next(&hole.sym->node); in find_symbol_hole_containing()
258 struct symbol *sym; in find_symbol_by_name() local
260 elf_hash_for_each_possible(symbol_name, sym, name_hash, str_hash(name)) { in find_symbol_by_name()
261 if (!strcmp(sym->name, name)) in find_symbol_by_name()
262 return sym; in find_symbol_by_name()
394 static void elf_add_symbol(struct elf *elf, struct symbol *sym) in elf_add_symbol() argument
400 INIT_LIST_HEAD(&sym->pv_target); in elf_add_symbol()
401 sym->alias = sym; in elf_add_symbol()
403 sym->type = GELF_ST_TYPE(sym->sym.st_info); in elf_add_symbol()
404 sym->bind = GELF_ST_BIND(sym->sym.st_info); in elf_add_symbol()
406 if (sym->type == STT_FILE) in elf_add_symbol()
409 sym->offset = sym->sym.st_value; in elf_add_symbol()
410 sym->len = sym->sym.st_size; in elf_add_symbol()
412 __sym_for_each(iter, &sym->sec->symbol_tree, sym->offset, sym->offset) { in elf_add_symbol()
413 if (iter->offset == sym->offset && iter->type == sym->type) in elf_add_symbol()
414 iter->alias = sym; in elf_add_symbol()
417 __sym_insert(sym, &sym->sec->symbol_tree); in elf_add_symbol()
418 pnode = rb_prev(&sym->node); in elf_add_symbol()
422 entry = &sym->sec->symbol_list; in elf_add_symbol()
423 list_add(&sym->list, entry); in elf_add_symbol()
424 elf_hash_add(symbol, &sym->hash, sym->idx); in elf_add_symbol()
425 elf_hash_add(symbol_name, &sym->name_hash, str_hash(sym->name)); in elf_add_symbol()
431 if (!sym->len) in elf_add_symbol()
432 __sym_remove(sym, &sym->sec->symbol_tree); in elf_add_symbol()
438 struct symbol *sym, *pfunc; in read_symbols() local
465 elf->symbol_data = calloc(symbols_nr, sizeof(*sym)); in read_symbols()
471 sym = &elf->symbol_data[i]; in read_symbols()
473 sym->idx = i; in read_symbols()
475 if (!gelf_getsymshndx(symtab->data, shndx_data, i, &sym->sym, in read_symbols()
481 sym->name = elf_strptr(elf->elf, symtab->sh.sh_link, in read_symbols()
482 sym->sym.st_name); in read_symbols()
483 if (!sym->name) { in read_symbols()
488 if ((sym->sym.st_shndx > SHN_UNDEF && in read_symbols()
489 sym->sym.st_shndx < SHN_LORESERVE) || in read_symbols()
490 (shndx_data && sym->sym.st_shndx == SHN_XINDEX)) { in read_symbols()
491 if (sym->sym.st_shndx != SHN_XINDEX) in read_symbols()
492 shndx = sym->sym.st_shndx; in read_symbols()
494 sym->sec = find_section_by_index(elf, shndx); in read_symbols()
495 if (!sym->sec) { in read_symbols()
497 sym->name); in read_symbols()
500 if (GELF_ST_TYPE(sym->sym.st_info) == STT_SECTION) { in read_symbols()
501 sym->name = sym->sec->name; in read_symbols()
502 sym->sec->sym = sym; in read_symbols()
505 sym->sec = find_section_by_index(elf, 0); in read_symbols()
507 elf_add_symbol(elf, sym); in read_symbols()
517 sec_for_each_sym(sec, sym) { in read_symbols()
520 if (sym->type != STT_FUNC) in read_symbols()
523 if (sym->pfunc == NULL) in read_symbols()
524 sym->pfunc = sym; in read_symbols()
526 if (sym->cfunc == NULL) in read_symbols()
527 sym->cfunc = sym; in read_symbols()
529 coldstr = strstr(sym->name, ".cold"); in read_symbols()
533 pnamelen = coldstr - sym->name; in read_symbols()
536 sym->name, MAX_NAME_LEN); in read_symbols()
540 strncpy(pname, sym->name, pnamelen); in read_symbols()
546 sym->name); in read_symbols()
550 sym->pfunc = pfunc; in read_symbols()
551 pfunc->cfunc = sym; in read_symbols()
561 if (sym->sec == pfunc->sec && in read_symbols()
562 sym->offset >= pfunc->offset && in read_symbols()
563 sym->offset + sym->len == pfunc->offset + pfunc->len) { in read_symbols()
564 pfunc->len -= sym->len; in read_symbols()
572 free(sym); in read_symbols()
579 static int elf_update_sym_relocs(struct elf *elf, struct symbol *sym) in elf_update_sym_relocs() argument
583 for (reloc = sym->relocs; reloc; reloc = reloc->sym_next_reloc) in elf_update_sym_relocs()
584 set_reloc_sym(elf, reloc, reloc->sym->idx); in elf_update_sym_relocs()
598 struct section *symtab_shndx, struct symbol *sym) in elf_update_symbol() argument
600 Elf32_Word shndx = sym->sec ? sym->sec->idx : SHN_UNDEF; in elf_update_symbol()
603 int max_idx, idx = sym->idx; in elf_update_symbol()
605 bool is_special_shndx = sym->sym.st_shndx >= SHN_LORESERVE && in elf_update_symbol()
606 sym->sym.st_shndx != SHN_XINDEX; in elf_update_symbol()
609 shndx = sym->sym.st_shndx; in elf_update_symbol()
638 int num = max(1U, sym->idx/3); in elf_update_symbol()
708 sym->sym.st_shndx = shndx; in elf_update_symbol()
712 sym->sym.st_shndx = SHN_XINDEX; in elf_update_symbol()
719 if (!gelf_update_symshndx(symtab_data, shndx_data, idx, &sym->sym, shndx)) { in elf_update_symbol()
728 __elf_create_symbol(struct elf *elf, struct symbol *sym) in __elf_create_symbol() argument
744 if (GELF_ST_BIND(sym->sym.st_info) != STB_LOCAL) in __elf_create_symbol()
776 sym->idx = new_idx; in __elf_create_symbol()
777 if (elf_update_symbol(elf, symtab, symtab_shndx, sym)) { in __elf_create_symbol()
790 return sym; in __elf_create_symbol()
796 struct symbol *sym = calloc(1, sizeof(*sym)); in elf_create_section_symbol() local
798 if (!sym) { in elf_create_section_symbol()
803 sym->name = sec->name; in elf_create_section_symbol()
804 sym->sec = sec; in elf_create_section_symbol()
807 sym->sym.st_info = GELF_ST_INFO(STB_LOCAL, STT_SECTION); in elf_create_section_symbol()
812 sym = __elf_create_symbol(elf, sym); in elf_create_section_symbol()
813 if (sym) in elf_create_section_symbol()
814 elf_add_symbol(elf, sym); in elf_create_section_symbol()
816 return sym; in elf_create_section_symbol()
824 struct symbol *sym = calloc(1, sizeof(*sym)); in elf_create_prefix_symbol() local
828 if (!sym || !name) { in elf_create_prefix_symbol()
835 sym->name = name; in elf_create_prefix_symbol()
836 sym->sec = orig->sec; in elf_create_prefix_symbol()
838 sym->sym.st_name = elf_add_string(elf, NULL, name); in elf_create_prefix_symbol()
839 sym->sym.st_info = orig->sym.st_info; in elf_create_prefix_symbol()
840 sym->sym.st_value = orig->sym.st_value - size; in elf_create_prefix_symbol()
841 sym->sym.st_size = size; in elf_create_prefix_symbol()
843 sym = __elf_create_symbol(elf, sym); in elf_create_prefix_symbol()
844 if (sym) in elf_create_prefix_symbol()
845 elf_add_symbol(elf, sym); in elf_create_prefix_symbol()
847 return sym; in elf_create_prefix_symbol()
852 unsigned long offset, struct symbol *sym, in elf_init_reloc() argument
872 reloc->sym = sym; in elf_init_reloc()
875 set_reloc_sym(elf, reloc, sym->idx); in elf_init_reloc()
880 reloc->sym_next_reloc = sym->relocs; in elf_init_reloc()
881 sym->relocs = reloc; in elf_init_reloc()
892 struct symbol *sym = insn_sec->sym; in elf_init_reloc_text_sym() local
897 __func__, sym->name); in elf_init_reloc_text_sym()
901 if (!sym) { in elf_init_reloc_text_sym()
908 sym = elf_create_section_symbol(elf, insn_sec); in elf_init_reloc_text_sym()
909 if (!sym) in elf_init_reloc_text_sym()
912 insn_sec->sym = sym; in elf_init_reloc_text_sym()
915 return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend, in elf_init_reloc_text_sym()
922 struct symbol *sym, in elf_init_reloc_data_sym() argument
925 if (sym->sec && (sec->sh.sh_flags & SHF_EXECINSTR)) { in elf_init_reloc_data_sym()
927 __func__, sym->name); in elf_init_reloc_data_sym()
931 return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend, in elf_init_reloc_data_sym()
941 struct symbol *sym; in read_relocs() local
971 reloc->sym = sym = find_symbol_by_index(elf, symndx); in read_relocs()
972 if (!reloc->sym) { in read_relocs()
979 reloc->sym_next_reloc = sym->relocs; in read_relocs()
980 sym->relocs = reloc; in read_relocs()