Lines Matching refs:elf

299 static int sanity_check_usdt_elf(Elf *elf, const char *path)  in sanity_check_usdt_elf()  argument
304 if (elf_kind(elf) != ELF_K_ELF) { in sanity_check_usdt_elf()
305 pr_warn("usdt: unrecognized ELF kind %d for '%s'\n", elf_kind(elf), path); in sanity_check_usdt_elf()
309 switch (gelf_getclass(elf)) { in sanity_check_usdt_elf()
327 if (!gelf_getehdr(elf, &ehdr)) in sanity_check_usdt_elf()
351 static int find_elf_sec_by_name(Elf *elf, const char *sec_name, GElf_Shdr *shdr, Elf_Scn **scn) in find_elf_sec_by_name() argument
356 if (elf_getshdrstrndx(elf, &shstrndx)) in find_elf_sec_by_name()
360 if (!elf_rawdata(elf_getscn(elf, shstrndx), NULL)) in find_elf_sec_by_name()
363 while ((sec = elf_nextscn(elf, sec)) != NULL) { in find_elf_sec_by_name()
369 name = elf_strptr(elf, shstrndx, shdr->sh_name); in find_elf_sec_by_name()
394 static int parse_elf_segs(Elf *elf, const char *path, struct elf_seg **segs, size_t *seg_cnt) in parse_elf_segs() argument
404 if (elf_getphdrnum(elf, &n)) { in parse_elf_segs()
410 if (!gelf_getphdr(elf, i, &phdr)) { in parse_elf_segs()
566 static int parse_usdt_note(Elf *elf, const char *path, GElf_Nhdr *nhdr,
572 static int collect_usdt_targets(struct usdt_manager *man, Elf *elf, const char *path, pid_t pid, in collect_usdt_targets() argument
590 err = find_elf_sec_by_name(elf, USDT_NOTE_SEC, &notes_shdr, &notes_scn); in collect_usdt_targets()
596 if (notes_shdr.sh_type != SHT_NOTE || !gelf_getehdr(elf, &ehdr)) { in collect_usdt_targets()
601 err = parse_elf_segs(elf, path, &segs, &seg_cnt); in collect_usdt_targets()
610 if (find_elf_sec_by_name(elf, USDT_BASE_SEC, &base_shdr, &base_scn) == 0) in collect_usdt_targets()
621 err = parse_usdt_note(elf, path, &nhdr, data->d_buf, name_off, desc_off, &note); in collect_usdt_targets()
952 Elf *elf; in usdt_manager_attach_usdt() local
965 elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); in usdt_manager_attach_usdt()
966 if (!elf) { in usdt_manager_attach_usdt()
972 err = sanity_check_usdt_elf(elf, path); in usdt_manager_attach_usdt()
985 err = collect_usdt_targets(man, elf, path, pid, usdt_provider, usdt_name, in usdt_manager_attach_usdt()
1070 elf_end(elf); in usdt_manager_attach_usdt()
1080 if (elf) in usdt_manager_attach_usdt()
1081 elf_end(elf); in usdt_manager_attach_usdt()
1089 static int parse_usdt_note(Elf *elf, const char *path, GElf_Nhdr *nhdr, in parse_usdt_note() argument