Lines Matching refs:kcore

1914 struct kcore {
1921 static int kcore__open(struct kcore *kcore, const char *filename)
1925 kcore->fd = open(filename, O_RDONLY);
1926 if (kcore->fd == -1)
1929 kcore->elf = elf_begin(kcore->fd, ELF_C_READ, NULL);
1930 if (!kcore->elf)
1933 kcore->elfclass = gelf_getclass(kcore->elf);
1934 if (kcore->elfclass == ELFCLASSNONE)
1937 ehdr = gelf_getehdr(kcore->elf, &kcore->ehdr);
1944 elf_end(kcore->elf);
1946 close(kcore->fd);
1950 static int kcore__init(struct kcore *kcore, char *filename, int elfclass,
1953 kcore->elfclass = elfclass;
1956 kcore->fd = mkstemp(filename);
1958 kcore->fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0400);
1959 if (kcore->fd == -1)
1962 kcore->elf = elf_begin(kcore->fd, ELF_C_WRITE, NULL);
1963 if (!kcore->elf)
1966 if (!gelf_newehdr(kcore->elf, elfclass))
1969 memset(&kcore->ehdr, 0, sizeof(GElf_Ehdr));
1974 elf_end(kcore->elf);
1976 close(kcore->fd);
1981 static void kcore__close(struct kcore *kcore)
1983 elf_end(kcore->elf);
1984 close(kcore->fd);
1987 static int kcore__copy_hdr(struct kcore *from, struct kcore *to, size_t count)
2023 static int kcore__add_phdr(struct kcore *kcore, int idx, off_t offset,
2037 if (!gelf_update_phdr(kcore->elf, idx, &phdr))
2043 static off_t kcore__write(struct kcore *kcore)
2045 return elf_update(kcore->elf, ELF_C_WRITE);
2463 * kcore_copy - copy kallsyms, modules and kcore from one directory to another.
2467 * This function copies kallsyms, modules and kcore files from one directory to
2469 * copied from kcore. It is assumed that two segments suffice: one for the
2477 * symbol too. Because it contains only code sections, the resulting kcore is
2480 * the data is copied adjacently whereas the original kcore has gaps. Finally,
2488 struct kcore kcore;
2489 struct kcore extract;
2506 scnprintf(kcore_filename, PATH_MAX, "%s/kcore", from_dir);
2507 scnprintf(extract_filename, PATH_MAX, "%s/kcore", to_dir);
2509 if (kcore__open(&kcore, kcore_filename))
2512 if (kcore_copy__calc_maps(&kci, from_dir, kcore.elf))
2515 if (kcore__init(&extract, extract_filename, kcore.elfclass, false))
2518 if (kcore__copy_hdr(&kcore, &extract, kci.phnum))
2541 if (copy_bytes(kcore.fd, p->offset, extract.fd, offs, p->len))
2555 kcore__close(&kcore);
2571 struct kcore kcore;
2572 struct kcore extract;
2577 if (kcore__open(&kcore, kce->kcore_filename))
2581 if (kcore__init(&extract, kce->extract_filename, kcore.elfclass, true))
2584 if (kcore__copy_hdr(&kcore, &extract, count))
2594 if (copy_bytes(kcore.fd, kce->offs, extract.fd, offset, kce->len))
2604 kcore__close(&kcore);