Lines Matching full:elf
67 * to that, those USDT macros generate special SHT_NOTE ELF records in
68 * .note.stapsdt ELF section. Here's an example USDT definition as emitted by
84 * refcount variable (normally in '.probes' ELF section) used for signaling if
316 static int sanity_check_usdt_elf(Elf *elf, const char *path)
321 if (elf_kind(elf) != ELF_K_ELF) {
322 pr_warn("usdt: unrecognized ELF kind %d for '%s'\n", elf_kind(elf), path);
326 switch (gelf_getclass(elf)) {
329 pr_warn("usdt: attaching to 64-bit ELF binary '%s' is not supported\n", path);
335 pr_warn("usdt: attaching to 32-bit ELF binary '%s' is not supported\n", path);
340 pr_warn("usdt: unsupported ELF class for '%s'\n", path);
344 if (!gelf_getehdr(elf, &ehdr))
348 pr_warn("usdt: unsupported type of ELF binary '%s' (%d), only ET_EXEC and ET_DYN are supported\n",
361 pr_warn("usdt: ELF endianness mismatch for '%s'\n", path);
368 static int find_elf_sec_by_name(Elf *elf, const char *sec_name, GElf_Shdr *shdr, Elf_Scn **scn)
373 if (elf_getshdrstrndx(elf, &shstrndx))
376 /* check if ELF is corrupted and avoid calling elf_strptr if yes */
377 if (!elf_rawdata(elf_getscn(elf, shstrndx), NULL))
380 while ((sec = elf_nextscn(elf, sec)) != NULL) {
386 name = elf_strptr(elf, shstrndx, shdr->sh_name);
411 static int parse_elf_segs(Elf *elf, const char *path, struct elf_seg **segs, size_t *seg_cnt)
421 if (elf_getphdrnum(elf, &n)) {
427 if (!gelf_getphdr(elf, i, &phdr)) {
556 /* for ELF binaries (both executables and shared libraries), we are
588 static int collect_usdt_targets(struct usdt_manager *man, Elf *elf, const char *path, pid_t pid,
606 err = find_elf_sec_by_name(elf, USDT_NOTE_SEC, ¬es_shdr, ¬es_scn);
612 if (notes_shdr.sh_type != SHT_NOTE || !gelf_getehdr(elf, &ehdr)) {
617 err = parse_elf_segs(elf, path, &segs, &seg_cnt);
619 pr_warn("usdt: failed to process ELF program segments for '%s': %s\n",
624 /* .stapsdt.base ELF section is optional, but is used for prelink
627 if (find_elf_sec_by_name(elf, USDT_BASE_SEC, &base_shdr, &base_scn) == 0)
648 * Each SDT probe also expands into a non-allocated ELF note. You can
684 pr_warn("usdt: failed to find ELF program segment for '%s:%s' in '%s' at IP 0x%lx\n",
690 pr_warn("usdt: matched ELF binary '%s' segment [0x%lx, 0x%lx) for '%s:%s' at IP 0x%lx is not executable\n",
756 pr_warn("usdt: failed to find ELF loadable segment with semaphore of '%s:%s' in '%s' at 0x%lx\n",
762 pr_warn("usdt: matched ELF binary '%s' segment [0x%lx, 0x%lx] for semaphore of '%s:%s' at 0x%lx is executable\n",
791 /* notes.args references strings from ELF itself, so they can
988 err = sanity_check_usdt_elf(elf_fd.elf, path);
1001 err = collect_usdt_targets(man, elf_fd.elf, path, pid, usdt_provider, usdt_name,
1141 /* Parse out USDT ELF note from '.note.stapsdt' section.
1157 /* sanity check USDT note contents ("description" in ELF terminology) */