Lines Matching full:elf

17 	Elf *elf;  in elf_open()  local
20 pr_warn("elf: failed to init libelf for %s\n", binary_path); in elf_open()
26 pr_warn("elf: failed to open %s: %s\n", binary_path, in elf_open()
30 elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); in elf_open()
31 if (!elf) { in elf_open()
32 pr_warn("elf: could not read elf from %s: %s\n", binary_path, elf_errmsg(-1)); in elf_open()
37 elf_fd->elf = elf; in elf_open()
45 elf_end(elf_fd->elf); in elf_close()
49 /* Return next ELF section of sh_type after scn, or first of that type if scn is NULL. */
50 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
52 while ((scn = elf_nextscn(elf, scn)) != NULL) { in elf_find_next_scn_by_type()
70 Elf *elf; member
80 Elf *elf, const char *binary_path, in elf_sym_iter_new() argument
89 if (!gelf_getehdr(elf, &ehdr)) { in elf_sym_iter_new()
90 pr_warn("elf: failed to get ehdr from %s: %s\n", binary_path, elf_errmsg(-1)); in elf_sym_iter_new()
94 scn = elf_find_next_scn_by_type(elf, sh_type, NULL); in elf_sym_iter_new()
96 pr_debug("elf: failed to find symbol table ELF sections in '%s'\n", in elf_sym_iter_new()
107 pr_warn("elf: failed to get symbols for symtab section in '%s': %s\n", in elf_sym_iter_new()
112 iter->elf = elf; in elf_sym_iter_new()
130 name = elf_strptr(iter->elf, iter->strtabidx, sym->st_name); in elf_sym_iter_next()
133 sym_scn = elf_getscn(iter->elf, sym->st_shndx); in elf_sym_iter_next()
161 /* Find offset of function name in the provided ELF object. "binary_path" is
162 * the path to the ELF binary represented by "elf", and only used for error
166 long elf_find_func_offset(Elf *elf, const char *binary_path, const char *name) in elf_find_func_offset() argument
174 if (!gelf_getehdr(elf, &ehdr)) { in elf_find_func_offset()
175 pr_warn("elf: failed to get ehdr from %s: %s\n", binary_path, elf_errmsg(-1)); in elf_find_func_offset()
197 ret = elf_sym_iter_new(&iter, elf, binary_path, sh_types[i], STT_FUNC); in elf_find_func_offset()
219 pr_warn("elf: ambiguous match for '%s', '%s' in '%s'\n", in elf_find_func_offset()
239 pr_debug("elf: symbol address match for '%s' in '%s': 0x%lx\n", name, binary_path, in elf_find_func_offset()
243 pr_warn("elf: '%s' is 0 in symtab for '%s': %s\n", name, binary_path, in elf_find_func_offset()
248 pr_warn("elf: failed to find symbol '%s' in '%s'\n", name, binary_path); in elf_find_func_offset()
255 /* Find offset of function name in ELF object specified by path. "name" matches
266 ret = elf_find_func_offset(elf_fd.elf, binary_path, name); in elf_find_func_offset_from_file()
322 err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], STT_FUNC); in elf_resolve_syms_offsets()
348 pr_warn("elf: ambiguous match found '%s@%lu' in '%s' previous offset %lu\n", in elf_resolve_syms_offsets()
403 err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], STT_FUNC); in elf_resolve_pattern_offsets()