Lines Matching full:elf
29 Elf *elf; in elf_open() local
31 elf_fd->elf = NULL; in elf_open()
35 pr_warn("elf: failed to init libelf for %s\n", binary_path); in elf_open()
41 pr_warn("elf: failed to open %s: %s\n", binary_path, in elf_open()
45 elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); in elf_open()
46 if (!elf) { in elf_open()
47 pr_warn("elf: could not read elf from %s: %s\n", binary_path, elf_errmsg(-1)); in elf_open()
52 elf_fd->elf = elf; in elf_open()
60 elf_end(elf_fd->elf); in elf_close()
64 /* Return next ELF section of sh_type after scn, or first of that type if scn is NULL. */
65 static Elf_Scn *elf_find_next_scn_by_type(Elf *elf, int sh_type, Elf_Scn *scn) in elf_find_next_scn_by_type() argument
67 while ((scn = elf_nextscn(elf, scn)) != NULL) { in elf_find_next_scn_by_type()
87 Elf *elf; member
100 Elf *elf, const char *binary_path, in elf_sym_iter_new() argument
109 if (!gelf_getehdr(elf, &ehdr)) { in elf_sym_iter_new()
110 pr_warn("elf: failed to get ehdr from %s: %s\n", binary_path, elf_errmsg(-1)); in elf_sym_iter_new()
114 scn = elf_find_next_scn_by_type(elf, sh_type, NULL); in elf_sym_iter_new()
116 pr_debug("elf: failed to find symbol table ELF sections in '%s'\n", in elf_sym_iter_new()
127 pr_warn("elf: failed to get symbols for symtab section in '%s': %s\n", in elf_sym_iter_new()
132 iter->elf = elf; in elf_sym_iter_new()
139 scn = elf_find_next_scn_by_type(elf, SHT_GNU_versym, NULL); in elf_sym_iter_new()
144 scn = elf_find_next_scn_by_type(elf, SHT_GNU_verdef, NULL); in elf_sym_iter_new()
150 pr_warn("elf: failed to get verdef ELF section in '%s'\n", binary_path); in elf_sym_iter_new()
172 name = elf_strptr(iter->elf, iter->strtabidx, sym->st_name); in elf_sym_iter_next()
175 sym_scn = elf_getscn(iter->elf, sym->st_shndx); in elf_sym_iter_next()
220 return elf_strptr(iter->elf, iter->verdef_strtabidx, verdaux.vda_name); in elf_get_vername()
248 * get version name from ELF verdef section for comparison. in symbol_match()
274 /* Find offset of function name in the provided ELF object. "binary_path" is
275 * the path to the ELF binary represented by "elf", and only used for error
279 long elf_find_func_offset(Elf *elf, const char *binary_path, const char *name) in elf_find_func_offset() argument
288 if (!gelf_getehdr(elf, &ehdr)) { in elf_find_func_offset()
289 pr_warn("elf: failed to get ehdr from %s: %s\n", binary_path, elf_errmsg(-1)); in elf_find_func_offset()
320 ret = elf_sym_iter_new(&iter, elf, binary_path, sh_types[i], STT_FUNC); in elf_find_func_offset()
339 pr_warn("elf: ambiguous match for '%s', '%s' in '%s'\n", in elf_find_func_offset()
359 pr_debug("elf: symbol address match for '%s' in '%s': 0x%lx\n", name, binary_path, in elf_find_func_offset()
363 pr_warn("elf: '%s' is 0 in symtab for '%s': %s\n", name, binary_path, in elf_find_func_offset()
368 pr_warn("elf: failed to find symbol '%s' in '%s'\n", name, binary_path); in elf_find_func_offset()
375 /* Find offset of function name in ELF object specified by path. "name" matches
386 ret = elf_find_func_offset(elf_fd.elf, binary_path, name); in elf_find_func_offset_from_file()
443 err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], st_type); in elf_resolve_syms_offsets()
469 pr_warn("elf: ambiguous match found '%s@%lu' in '%s' previous offset %lu\n", in elf_resolve_syms_offsets()
524 err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], STT_FUNC); in elf_resolve_pattern_offsets()