kcore 1305 tools/perf/util/symbol-elf.c static int kcore__open(struct kcore *kcore, const char *filename) kcore 1309 tools/perf/util/symbol-elf.c kcore->fd = open(filename, O_RDONLY); kcore 1310 tools/perf/util/symbol-elf.c if (kcore->fd == -1) kcore 1313 tools/perf/util/symbol-elf.c kcore->elf = elf_begin(kcore->fd, ELF_C_READ, NULL); kcore 1314 tools/perf/util/symbol-elf.c if (!kcore->elf) kcore 1317 tools/perf/util/symbol-elf.c kcore->elfclass = gelf_getclass(kcore->elf); kcore 1318 tools/perf/util/symbol-elf.c if (kcore->elfclass == ELFCLASSNONE) kcore 1321 tools/perf/util/symbol-elf.c ehdr = gelf_getehdr(kcore->elf, &kcore->ehdr); kcore 1328 tools/perf/util/symbol-elf.c elf_end(kcore->elf); kcore 1330 tools/perf/util/symbol-elf.c close(kcore->fd); kcore 1334 tools/perf/util/symbol-elf.c static int kcore__init(struct kcore *kcore, char *filename, int elfclass, kcore 1337 tools/perf/util/symbol-elf.c kcore->elfclass = elfclass; kcore 1340 tools/perf/util/symbol-elf.c kcore->fd = mkstemp(filename); kcore 1342 tools/perf/util/symbol-elf.c kcore->fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0400); kcore 1343 tools/perf/util/symbol-elf.c if (kcore->fd == -1) kcore 1346 tools/perf/util/symbol-elf.c kcore->elf = elf_begin(kcore->fd, ELF_C_WRITE, NULL); kcore 1347 tools/perf/util/symbol-elf.c if (!kcore->elf) kcore 1350 tools/perf/util/symbol-elf.c if (!gelf_newehdr(kcore->elf, elfclass)) kcore 1353 tools/perf/util/symbol-elf.c memset(&kcore->ehdr, 0, sizeof(GElf_Ehdr)); kcore 1358 tools/perf/util/symbol-elf.c elf_end(kcore->elf); kcore 1360 tools/perf/util/symbol-elf.c close(kcore->fd); kcore 1365 tools/perf/util/symbol-elf.c static void kcore__close(struct kcore *kcore) kcore 1367 tools/perf/util/symbol-elf.c elf_end(kcore->elf); kcore 1368 tools/perf/util/symbol-elf.c close(kcore->fd); kcore 1371 tools/perf/util/symbol-elf.c static int kcore__copy_hdr(struct kcore *from, struct kcore *to, size_t count) kcore 1407 tools/perf/util/symbol-elf.c static int kcore__add_phdr(struct kcore *kcore, int idx, off_t offset, kcore 1421 tools/perf/util/symbol-elf.c if (!gelf_update_phdr(kcore->elf, idx, &phdr)) kcore 1427 tools/perf/util/symbol-elf.c static off_t kcore__write(struct kcore *kcore) kcore 1429 tools/perf/util/symbol-elf.c return elf_update(kcore->elf, ELF_C_WRITE); kcore 1865 tools/perf/util/symbol-elf.c struct kcore kcore; kcore 1866 tools/perf/util/symbol-elf.c struct kcore extract; kcore 1886 tools/perf/util/symbol-elf.c if (kcore__open(&kcore, kcore_filename)) kcore 1889 tools/perf/util/symbol-elf.c if (kcore_copy__calc_maps(&kci, from_dir, kcore.elf)) kcore 1892 tools/perf/util/symbol-elf.c if (kcore__init(&extract, extract_filename, kcore.elfclass, false)) kcore 1895 tools/perf/util/symbol-elf.c if (kcore__copy_hdr(&kcore, &extract, kci.phnum)) kcore 1918 tools/perf/util/symbol-elf.c if (copy_bytes(kcore.fd, p->offset, extract.fd, offs, p->len)) kcore 1935 tools/perf/util/symbol-elf.c kcore__close(&kcore); kcore 1951 tools/perf/util/symbol-elf.c struct kcore kcore; kcore 1952 tools/perf/util/symbol-elf.c struct kcore extract; kcore 1957 tools/perf/util/symbol-elf.c if (kcore__open(&kcore, kce->kcore_filename)) kcore 1961 tools/perf/util/symbol-elf.c if (kcore__init(&extract, kce->extract_filename, kcore.elfclass, true)) kcore 1964 tools/perf/util/symbol-elf.c if (kcore__copy_hdr(&kcore, &extract, count)) kcore 1974 tools/perf/util/symbol-elf.c if (copy_bytes(kcore.fd, kce->offs, extract.fd, offset, kce->len)) kcore 1984 tools/perf/util/symbol-elf.c kcore__close(&kcore);