Lines Matching defs:elf
39 Elf *elf;
42 pr_warn("elf: failed to init libelf for %s\n", binary_path);
48 pr_warn("elf: failed to open %s: %s\n", binary_path,
52 elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
53 if (!elf) {
54 pr_warn("elf: could not read elf from %s: %s\n", binary_path, elf_errmsg(-1));
59 elf_fd->elf = elf;
69 pr_warn("elf: could not read elf from %s: %s\n", binary_path, elf_errmsg(-1));
72 elf_fd->elf = pelfio;
84 elf_end(elf_fd->elf);
87 elfio_delete(elf_fd->elf);
93 static Elf_Scn *elf_find_next_scn_by_type(Elf *elf, int sh_type, Elf_Scn *scn)
95 while ((scn = elf_nextscn(elf, scn)) != NULL) {
129 static int elf_sym_iter_new(struct elf_sym_iter *iter,pelfio_t elf, const char *binary_path, int sh_type, int st_type)
133 pSec = elf_find_next_scn_by_type(elf, sh_type, NULL);
138 pr_warn("elf: failed to get symbols for symtab section in '%s': %s\n",
144 iter->elf = elf;
149 pSec = elf_find_next_scn_by_type(elf, SHT_GNU_versym, NULL);
155 pSec = elf_find_next_scn_by_type(elf, SHT_GNU_verdef, NULL);
162 pr_warn("elf: failed to get verdef ELF section in '%s'\n", binary_path);
170 static GElf_Shdr *elf_sec_hdr_by_idx(const pelfio_t elf, size_t idx, GElf_Shdr *sheader)
172 psection_t psection = elfio_get_section_by_index(elf, idx);
206 name = elf_strptr(iter->elf, iter->strtabidx, sym->st_name);
209 sym_scn = elf_getscn(iter->elf, sym->st_shndx);
221 psection_t psection = elfio_get_section_by_index(iter->elf, iter->strtabidx);
229 if(!elf_sec_hdr_by_idx(iter->elf, sym->st_shndx, &ret->sh)) {
270 return elf_strptr(iter->elf, iter->verdef_strtabidx, verdaux.vda_name);
283 psection_t psection = elfio_get_section_by_index(iter->elf, iter->verdef_strtabidx);
342 * the path to the ELF binary represented by "elf", and only used for error
347 long elf_find_func_offset(Elf *elf, const char *binary_path, const char *name)
349 long elf_find_func_offset(pelfio_t elf, const char *binary_path, const char *name)
360 if (!gelf_getehdr(elf, &ehdr)) {
361 pr_warn("elf: failed to get ehdr from %s: %s\n", binary_path, elf_errmsg(-1));
395 ret = elf_sym_iter_new(&iter, elf, binary_path, sh_types[i], STT_FUNC);
414 pr_warn("elf: ambiguous match for '%s', '%s' in '%s'\n",
434 pr_debug("elf: symbol address match for '%s' in '%s': 0x%lx\n", name, binary_path,
438 pr_warn("elf: '%s' is 0 in symtab for '%s': %s\n", name, binary_path,
443 pr_warn("elf: failed to find symbol '%s' in '%s'\n", name, binary_path);
461 ret = elf_find_func_offset(elf_fd.elf, binary_path, name);
517 err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], STT_FUNC);
543 pr_warn("elf: ambiguous match found '%s@%lu' in '%s' previous offset %lu\n",
598 err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], STT_FUNC);