Lines Matching refs:efile
704 struct elf_state efile; member
871 Elf_Data *symbols = obj->efile.symbols; in bpf_object__add_programs()
907 if (sec_idx != obj->efile.text_shndx && ELF64_ST_BIND(sym->st_info) == STB_LOCAL) { in bpf_object__add_programs()
1466 for (sec_idx = 0; sec_idx < obj->efile.sec_cnt; ++sec_idx) { in bpf_object_init_struct_ops()
1467 struct elf_sec_desc *desc = &obj->efile.secs[sec_idx]; in bpf_object_init_struct_ops()
1509 obj->efile.fd = -1; in bpf_object__new()
1516 obj->efile.obj_buf = obj_buf; in bpf_object__new()
1517 obj->efile.obj_buf_sz = obj_buf_sz; in bpf_object__new()
1518 obj->efile.btf_maps_shndx = -1; in bpf_object__new()
1530 if (!obj->efile.elf) in bpf_object__elf_finish()
1533 elf_end(obj->efile.elf); in bpf_object__elf_finish()
1534 obj->efile.elf = NULL; in bpf_object__elf_finish()
1535 obj->efile.ehdr = NULL; in bpf_object__elf_finish()
1536 obj->efile.symbols = NULL; in bpf_object__elf_finish()
1537 obj->efile.arena_data = NULL; in bpf_object__elf_finish()
1539 zfree(&obj->efile.secs); in bpf_object__elf_finish()
1540 obj->efile.sec_cnt = 0; in bpf_object__elf_finish()
1541 zclose(obj->efile.fd); in bpf_object__elf_finish()
1542 obj->efile.obj_buf = NULL; in bpf_object__elf_finish()
1543 obj->efile.obj_buf_sz = 0; in bpf_object__elf_finish()
1552 if (obj->efile.elf) { in bpf_object__elf_init()
1557 if (obj->efile.obj_buf_sz > 0) { in bpf_object__elf_init()
1559 elf = elf_memory((char *)obj->efile.obj_buf, obj->efile.obj_buf_sz); in bpf_object__elf_init()
1561 obj->efile.fd = open(obj->path, O_RDONLY | O_CLOEXEC); in bpf_object__elf_init()
1562 if (obj->efile.fd < 0) { in bpf_object__elf_init()
1568 elf = elf_begin(obj->efile.fd, ELF_C_READ_MMAP, NULL); in bpf_object__elf_init()
1577 obj->efile.elf = elf; in bpf_object__elf_init()
1591 obj->efile.ehdr = ehdr = elf64_getehdr(elf); in bpf_object__elf_init()
1592 if (!obj->efile.ehdr) { in bpf_object__elf_init()
1608 if (elf_getshdrstrndx(elf, &obj->efile.shstrndx)) { in bpf_object__elf_init()
1616 if (!elf_rawdata(elf_getscn(elf, obj->efile.shstrndx), NULL)) { in bpf_object__elf_init()
1705 Elf_Data *symbols = obj->efile.symbols; in find_elf_var_sym()
1995 for (sec_idx = 1; sec_idx < obj->efile.sec_cnt; sec_idx++) { in bpf_object__init_global_data_maps()
1996 sec_desc = &obj->efile.secs[sec_idx]; in bpf_object__init_global_data_maps()
2358 ".kconfig", obj->efile.symbols_shndx, in bpf_object__init_kconfig_map()
2997 if (obj->efile.btf_maps_shndx < 0) in bpf_object__init_user_btf_maps()
3000 scn = elf_sec_by_idx(obj, obj->efile.btf_maps_shndx); in bpf_object__init_user_btf_maps()
3016 obj->efile.btf_maps_sec_btf_id = i; in bpf_object__init_user_btf_maps()
3029 obj->efile.btf_maps_shndx, in bpf_object__init_user_btf_maps()
3049 if (obj->efile.arena_data) { in bpf_object__init_user_btf_maps()
3050 err = init_arena_map_data(obj, map, ARENA_SEC, obj->efile.arena_data_shndx, in bpf_object__init_user_btf_maps()
3051 obj->efile.arena_data->d_buf, in bpf_object__init_user_btf_maps()
3052 obj->efile.arena_data->d_size); in bpf_object__init_user_btf_maps()
3057 if (obj->efile.arena_data && obj->arena_map_idx < 0) { in bpf_object__init_user_btf_maps()
3226 return obj->efile.btf_maps_shndx >= 0 || in libbpf_needs_btf()
3227 obj->efile.has_st_ops || in libbpf_needs_btf()
3233 return obj->efile.has_st_ops; in kernel_needs_btf()
3632 name = elf_strptr(obj->efile.elf, obj->efile.strtabidx, off); in elf_sym_str()
3646 name = elf_strptr(obj->efile.elf, obj->efile.shstrndx, off); in elf_sec_str()
3660 scn = elf_getscn(obj->efile.elf, idx); in elf_sec_by_idx()
3672 Elf *elf = obj->efile.elf; in elf_sec_by_name()
3747 if (idx >= obj->efile.symbols->d_size / sizeof(Elf64_Sym)) in elf_sym_by_idx()
3750 return (Elf64_Sym *)obj->efile.symbols->d_buf + idx; in elf_sym_by_idx()
3816 Elf *elf = obj->efile.elf; in bpf_object__elf_collect()
3830 if (elf_getshdrnum(obj->efile.elf, &obj->efile.sec_cnt)) { in bpf_object__elf_collect()
3835 obj->efile.secs = calloc(obj->efile.sec_cnt, sizeof(*obj->efile.secs)); in bpf_object__elf_collect()
3836 if (!obj->efile.secs) in bpf_object__elf_collect()
3849 if (obj->efile.symbols) { in bpf_object__elf_collect()
3860 obj->efile.symbols = data; in bpf_object__elf_collect()
3861 obj->efile.symbols_shndx = idx; in bpf_object__elf_collect()
3862 obj->efile.strtabidx = sh->sh_link; in bpf_object__elf_collect()
3866 if (!obj->efile.symbols) { in bpf_object__elf_collect()
3875 sec_desc = &obj->efile.secs[idx]; in bpf_object__elf_collect()
3909 obj->efile.btf_maps_shndx = idx; in bpf_object__elf_collect()
3923 obj->efile.text_shndx = idx; in bpf_object__elf_collect()
3944 obj->efile.has_st_ops = true; in bpf_object__elf_collect()
3946 obj->efile.arena_data = data; in bpf_object__elf_collect()
3947 obj->efile.arena_data_shndx = idx; in bpf_object__elf_collect()
3956 targ_sec_idx >= obj->efile.sec_cnt) in bpf_object__elf_collect()
3986 if (!obj->efile.strtabidx || obj->efile.strtabidx > idx) { in bpf_object__elf_collect()
4221 if (!obj->efile.symbols) in bpf_object__collect_externs()
4224 scn = elf_sec_by_idx(obj, obj->efile.symbols_shndx); in bpf_object__collect_externs()
4433 return prog->sec_idx == obj->efile.text_shndx; in prog_is_subprog()
4454 switch (obj->efile.secs[shndx].sec_type) { in bpf_object__shndx_is_data()
4467 return shndx == obj->efile.btf_maps_shndx; in bpf_object__shndx_is_maps()
4473 if (shndx == obj->efile.symbols_shndx) in bpf_object__section_to_libbpf_map_type()
4476 switch (obj->efile.secs[shndx].sec_type) { in bpf_object__section_to_libbpf_map_type()
4540 if (!shdr_idx || shdr_idx != obj->efile.text_shndx) { in bpf_program__record_reloc()
4564 if (sym_is_subprog(sym, obj->efile.text_shndx)) { in bpf_program__record_reloc()
4584 if (shdr_idx == obj->efile.arena_data_shndx) { in bpf_program__record_reloc()
4709 if (sec_idx >= obj->efile.sec_cnt) in bpf_object__collect_prog_relos()
4741 if (sym->st_shndx >= obj->efile.sec_cnt) { in bpf_object__collect_prog_relos()
4805 if (map->sec_idx == obj->efile.btf_maps_shndx || bpf_map__is_struct_ops(map)) in map_fill_btf_type_info()
6478 subprog = find_prog_by_sec_insn(obj, obj->efile.text_shndx, sub_insn_idx); in bpf_object__reloc_code()
7200 if (!obj->efile.btf_maps_sec_btf_id || !obj->btf) in bpf_object__collect_map_relos()
7202 sec = btf__type_by_id(obj->btf, obj->efile.btf_maps_sec_btf_id); in bpf_object__collect_map_relos()
7228 if (map->sec_idx != obj->efile.btf_maps_shndx) in bpf_object__collect_map_relos()
7246 if (sym->st_shndx != obj->efile.btf_maps_shndx) { in bpf_object__collect_map_relos()
7324 for (i = 0; i < obj->efile.sec_cnt; i++) { in bpf_object__collect_relos()
7325 struct elf_sec_desc *sec_desc = &obj->efile.secs[i]; in bpf_object__collect_relos()
7337 if (shdr->sh_type != SHT_REL || idx < 0 || idx >= obj->efile.sec_cnt) { in bpf_object__collect_relos()
7342 if (obj->efile.secs[idx].sec_type == SEC_ST_OPS) in bpf_object__collect_relos()
7344 else if (idx == obj->efile.btf_maps_shndx) in bpf_object__collect_relos()