Lines Matching refs:sym
155 struct symbol *sym;
157 elf_hash_for_each_possible(elf->symbol_hash, sym, hash, idx)
158 if (sym->idx == idx)
159 return sym;
222 struct symbol *sym;
224 elf_hash_for_each_possible(elf->symbol_name_hash, sym, name_hash, str_hash(name))
225 if (!strcmp(sym->name, name))
226 return sym;
344 static void elf_add_symbol(struct elf *elf, struct symbol *sym)
349 sym->alias = sym;
351 sym->type = GELF_ST_TYPE(sym->sym.st_info);
352 sym->bind = GELF_ST_BIND(sym->sym.st_info);
354 sym->offset = sym->sym.st_value;
355 sym->len = sym->sym.st_size;
357 rb_add(&sym->sec->symbol_tree, &sym->node, symbol_to_offset);
358 pnode = rb_prev(&sym->node);
362 entry = &sym->sec->symbol_list;
363 list_add(&sym->list, entry);
364 elf_hash_add(elf->symbol_hash, &sym->hash, sym->idx);
365 elf_hash_add(elf->symbol_name_hash, &sym->name_hash, str_hash(sym->name));
371 if (!sym->len)
372 rb_erase(&sym->node, &sym->sec->symbol_tree);
378 struct symbol *sym, *pfunc;
400 sym = malloc(sizeof(*sym));
401 if (!sym) {
405 memset(sym, 0, sizeof(*sym));
407 sym->idx = i;
409 if (!gelf_getsymshndx(symtab->data, shndx_data, i, &sym->sym,
415 sym->name = elf_strptr(elf->elf, symtab->sh.sh_link,
416 sym->sym.st_name);
417 if (!sym->name) {
422 if ((sym->sym.st_shndx > SHN_UNDEF &&
423 sym->sym.st_shndx < SHN_LORESERVE) ||
424 (shndx_data && sym->sym.st_shndx == SHN_XINDEX)) {
425 if (sym->sym.st_shndx != SHN_XINDEX)
426 shndx = sym->sym.st_shndx;
428 sym->sec = find_section_by_index(elf, shndx);
429 if (!sym->sec) {
431 sym->name);
434 if (GELF_ST_TYPE(sym->sym.st_info) == STT_SECTION) {
435 sym->name = sym->sec->name;
436 sym->sec->sym = sym;
439 sym->sec = find_section_by_index(elf, 0);
441 elf_add_symbol(elf, sym);
449 list_for_each_entry(sym, &sec->symbol_list, list) {
452 if (sym->type != STT_FUNC)
455 if (sym->pfunc == NULL)
456 sym->pfunc = sym;
458 if (sym->cfunc == NULL)
459 sym->cfunc = sym;
461 coldstr = strstr(sym->name, ".cold");
465 pnamelen = coldstr - sym->name;
468 sym->name, MAX_NAME_LEN);
472 strncpy(pname, sym->name, pnamelen);
478 sym->name);
482 sym->pfunc = pfunc;
483 pfunc->cfunc = sym;
491 * pfunc->sym.st_size.
493 if (sym->sec == pfunc->sec &&
494 sym->offset >= pfunc->offset &&
495 sym->offset + sym->len == pfunc->offset + pfunc->len) {
496 pfunc->len -= sym->len;
504 free(sym);
513 unsigned int type, struct symbol *sym, s64 addend)
530 reloc->sym = sym;
542 * Ensure that any reloc section containing references to @sym is marked
546 static void elf_dirty_reloc_sym(struct elf *elf, struct symbol *sym)
557 if (reloc->sym == sym) {
574 struct section *symtab_shndx, struct symbol *sym)
576 Elf32_Word shndx = sym->sec ? sym->sec->idx : SHN_UNDEF;
579 int max_idx, idx = sym->idx;
581 bool is_special_shndx = sym->sym.st_shndx >= SHN_LORESERVE &&
582 sym->sym.st_shndx != SHN_XINDEX;
585 shndx = sym->sym.st_shndx;
637 shndx_data->d_buf = &sym->sec->idx;
672 sym->sym.st_shndx = shndx;
676 sym->sym.st_shndx = SHN_XINDEX;
683 if (!gelf_update_symshndx(symtab_data, shndx_data, idx, &sym->sym, shndx)) {
696 struct symbol *sym, *old;
706 sym = calloc(1, sizeof(*sym));
707 if (!sym) {
712 sym->name = sec->name;
713 sym->sec = sec;
716 sym->sym.st_info = GELF_ST_INFO(STB_LOCAL, STT_SECTION);
744 sym->idx = new_idx;
745 if (elf_update_symbol(elf, symtab, symtab_shndx, sym)) {
755 elf_add_symbol(elf, sym);
757 return sym;
764 struct symbol *sym = insn_sec->sym;
767 if (!sym) {
774 sym = elf_create_section_symbol(elf, insn_sec);
775 if (!sym)
778 insn_sec->sym = sym;
781 return elf_add_reloc(elf, sec, offset, type, sym, addend);
854 reloc->sym = find_symbol_by_index(elf, symndx);
855 if (!reloc->sym) {
1154 relocs[idx].r_info = GELF_R_INFO(reloc->sym->idx, reloc->type);
1184 relocs[idx].r_info = GELF_R_INFO(reloc->sym->idx, reloc->type);
1231 reloc->rel.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type);
1239 reloc->rela.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type);
1300 struct symbol *sym, *tmpsym;
1310 list_for_each_entry_safe(sym, tmpsym, &sec->symbol_list, list) {
1311 list_del(&sym->list);
1312 hash_del(&sym->hash);
1313 free(sym);