Lines Matching refs:elf
41 static int elf_getphdrnum(Elf *elf, size_t *dst) in elf_getphdrnum() argument
46 ehdr = gelf_getehdr(elf, &gehdr); in elf_getphdrnum()
153 static size_t elf_addr_to_index(Elf *elf, GElf_Addr addr) in elf_addr_to_index() argument
159 while ((sec = elf_nextscn(elf, sec)) != NULL) { in elf_addr_to_index()
172 Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, in elf_section_by_name() argument
179 if (!elf_rawdata(elf_getscn(elf, ep->e_shstrndx), NULL)) in elf_section_by_name()
182 while ((sec = elf_nextscn(elf, sec)) != NULL) { in elf_section_by_name()
186 str = elf_strptr(elf, ep->e_shstrndx, shp->sh_name); in elf_section_by_name()
229 Elf *elf; in dso__synthesize_plt_symbols() local
235 elf = ss->elf; in dso__synthesize_plt_symbols()
245 scn_plt_rel = elf_section_by_name(elf, &ehdr, &shdr_rel_plt, in dso__synthesize_plt_symbols()
248 scn_plt_rel = elf_section_by_name(elf, &ehdr, &shdr_rel_plt, in dso__synthesize_plt_symbols()
259 if (elf_section_by_name(elf, &ehdr, &shdr_plt, ".plt", NULL) == NULL) in dso__synthesize_plt_symbols()
274 scn_symstrs = elf_getscn(elf, shdr_dynsym.sh_link); in dso__synthesize_plt_symbols()
349 static int elf_read_build_id(Elf *elf, void *bf, size_t size) in elf_read_build_id() argument
362 ek = elf_kind(elf); in elf_read_build_id()
366 if (gelf_getehdr(elf, &ehdr) == NULL) { in elf_read_build_id()
378 sec = elf_section_by_name(elf, &ehdr, &shdr, in elf_read_build_id()
383 sec = elf_section_by_name(elf, &ehdr, &shdr, in elf_read_build_id()
388 sec = elf_section_by_name(elf, &ehdr, &shdr, in elf_read_build_id()
431 Elf *elf; in filename__read_build_id() local
440 elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); in filename__read_build_id()
441 if (elf == NULL) { in filename__read_build_id()
446 err = elf_read_build_id(elf, bf, size); in filename__read_build_id()
448 elf_end(elf); in filename__read_build_id()
504 Elf *elf; in filename__read_debuglink() local
515 elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); in filename__read_debuglink()
516 if (elf == NULL) { in filename__read_debuglink()
521 ek = elf_kind(elf); in filename__read_debuglink()
525 if (gelf_getehdr(elf, &ehdr) == NULL) { in filename__read_debuglink()
530 sec = elf_section_by_name(elf, &ehdr, &shdr, in filename__read_debuglink()
545 elf_end(elf); in filename__read_debuglink()
629 elf_end(ss->elf); in symsrc__destroy()
643 Elf *elf; in symsrc__init() local
658 elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); in symsrc__init()
659 if (elf == NULL) { in symsrc__init()
665 if (gelf_getehdr(elf, &ehdr) == NULL) { in symsrc__init()
680 if (elf_read_build_id(elf, build_id, BUILD_ID_SIZE) < 0) { in symsrc__init()
692 ss->is_64_bit = (gelf_getclass(elf) == ELFCLASS64); in symsrc__init()
694 ss->symtab = elf_section_by_name(elf, &ehdr, &ss->symshdr, ".symtab", in symsrc__init()
700 ss->dynsym = elf_section_by_name(elf, &ehdr, &ss->dynshdr, ".dynsym", in symsrc__init()
706 ss->opdsec = elf_section_by_name(elf, &ehdr, &ss->opdshdr, ".opd", in symsrc__init()
716 elf_section_by_name(elf, &ehdr, &shdr, in symsrc__init()
729 ss->elf = elf; in symsrc__init()
737 elf_end(elf); in symsrc__init()
798 Elf *elf; in dso__load_sym() local
829 elf = syms_ss->elf; in dso__load_sym()
841 sec = elf_getscn(elf, shdr.sh_link); in dso__load_sym()
849 sec_strndx = elf_getscn(runtime_ss->elf, runtime_ss->ehdr.e_shstrndx); in dso__load_sym()
885 if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL)) in dso__load_sym()
922 sym.st_shndx = elf_addr_to_index(runtime_ss->elf, in dso__load_sym()
938 sec = elf_getscn(runtime_ss->elf, sym.st_shndx); in dso__load_sym()
1110 static int elf_read_maps(Elf *elf, bool exe, mapfn_t mapfn, void *data) in elf_read_maps() argument
1117 if (elf_getphdrnum(elf, &phdrnum)) in elf_read_maps()
1121 if (gelf_getphdr(elf, i, &phdr) == NULL) in elf_read_maps()
1146 Elf *elf; in file__read_maps() local
1148 elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); in file__read_maps()
1149 if (elf == NULL) in file__read_maps()
1153 *is_64_bit = (gelf_getclass(elf) == ELFCLASS64); in file__read_maps()
1155 err = elf_read_maps(elf, exe, mapfn, data); in file__read_maps()
1157 elf_end(elf); in file__read_maps()
1166 Elf *elf; in dso__type_fd() local
1168 elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); in dso__type_fd()
1169 if (elf == NULL) in dso__type_fd()
1172 ek = elf_kind(elf); in dso__type_fd()
1176 if (gelf_getclass(elf) == ELFCLASS64) { in dso__type_fd()
1181 if (gelf_getehdr(elf, &ehdr) == NULL) in dso__type_fd()
1189 elf_end(elf); in dso__type_fd()
1238 Elf *elf; member
1250 kcore->elf = elf_begin(kcore->fd, ELF_C_READ, NULL); in kcore__open()
1251 if (!kcore->elf) in kcore__open()
1254 kcore->elfclass = gelf_getclass(kcore->elf); in kcore__open()
1258 ehdr = gelf_getehdr(kcore->elf, &kcore->ehdr); in kcore__open()
1265 elf_end(kcore->elf); in kcore__open()
1283 kcore->elf = elf_begin(kcore->fd, ELF_C_WRITE, NULL); in kcore__init()
1284 if (!kcore->elf) in kcore__init()
1287 if (!gelf_newehdr(kcore->elf, elfclass)) in kcore__init()
1295 elf_end(kcore->elf); in kcore__init()
1304 elf_end(kcore->elf); in kcore__close()
1335 if (!gelf_update_ehdr(to->elf, ehdr)) in kcore__copy_hdr()
1338 if (!gelf_newphdr(to->elf, count)) in kcore__copy_hdr()
1358 if (!gelf_update_phdr(kcore->elf, idx, &phdr)) in kcore__add_phdr()
1366 return elf_update(kcore->elf, ELF_C_WRITE); in kcore__write()
1490 static int kcore_copy__read_maps(struct kcore_copy_info *kci, Elf *elf) in kcore_copy__read_maps() argument
1492 if (elf_read_maps(elf, true, kcore_copy__read_map, kci) < 0) in kcore_copy__read_maps()
1499 Elf *elf) in kcore_copy__calc_maps() argument
1533 return kcore_copy__read_maps(kci, elf); in kcore_copy__calc_maps()
1675 if (kcore_copy__calc_maps(&kci, from_dir, kcore.elf)) in kcore_copy()