Lines Matching refs:btf_ext
923 struct btf_ext **btf_ext)
992 } else if (btf_ext && strcmp(name, BTF_EXT_ELF_SEC) == 0) {
1025 if (btf_ext && btf_ext_data) {
1026 *btf_ext = btf_ext__new(btf_ext_data->d_buf, btf_ext_data->d_size);
1027 err = libbpf_get_error(*btf_ext);
1030 } else if (btf_ext) {
1031 *btf_ext = NULL;
1041 if (btf_ext)
1042 btf_ext__free(*btf_ext);
1048 struct btf *btf__parse_elf(const char *path, struct btf_ext **btf_ext)
1050 return libbpf_ptr(btf_parse_elf(path, NULL, btf_ext));
1131 static struct btf *btf_parse(const char *path, struct btf *base_btf, struct btf_ext **btf_ext)
1136 if (btf_ext)
1137 *btf_ext = NULL;
1145 return btf_parse_elf(path, base_btf, btf_ext);
1148 struct btf *btf__parse(const char *path, struct btf_ext **btf_ext)
1150 return libbpf_ptr(btf_parse(path, NULL, btf_ext));
2655 static int btf_ext_setup_info(struct btf_ext *btf_ext,
2674 info = btf_ext->data + btf_ext->hdr->hdr_len + ext_sec->off;
2677 if (btf_ext->data + btf_ext->data_size < info + ext_sec->len) {
2746 static int btf_ext_setup_func_info(struct btf_ext *btf_ext)
2749 .off = btf_ext->hdr->func_info_off,
2750 .len = btf_ext->hdr->func_info_len,
2752 .ext_info = &btf_ext->func_info,
2756 return btf_ext_setup_info(btf_ext, ¶m);
2759 static int btf_ext_setup_line_info(struct btf_ext *btf_ext)
2762 .off = btf_ext->hdr->line_info_off,
2763 .len = btf_ext->hdr->line_info_len,
2765 .ext_info = &btf_ext->line_info,
2769 return btf_ext_setup_info(btf_ext, ¶m);
2772 static int btf_ext_setup_core_relos(struct btf_ext *btf_ext)
2775 .off = btf_ext->hdr->core_relo_off,
2776 .len = btf_ext->hdr->core_relo_len,
2778 .ext_info = &btf_ext->core_relo_info,
2782 return btf_ext_setup_info(btf_ext, ¶m);
2821 void btf_ext__free(struct btf_ext *btf_ext)
2823 if (IS_ERR_OR_NULL(btf_ext))
2825 free(btf_ext->func_info.sec_idxs);
2826 free(btf_ext->line_info.sec_idxs);
2827 free(btf_ext->core_relo_info.sec_idxs);
2828 free(btf_ext->data);
2829 free(btf_ext);
2832 struct btf_ext *btf_ext__new(const __u8 *data, __u32 size)
2834 struct btf_ext *btf_ext;
2837 btf_ext = calloc(1, sizeof(struct btf_ext));
2838 if (!btf_ext)
2841 btf_ext->data_size = size;
2842 btf_ext->data = malloc(size);
2843 if (!btf_ext->data) {
2847 memcpy(btf_ext->data, data, size);
2849 err = btf_ext_parse_hdr(btf_ext->data, size);
2853 if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, line_info_len)) {
2858 err = btf_ext_setup_func_info(btf_ext);
2862 err = btf_ext_setup_line_info(btf_ext);
2866 if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, core_relo_len))
2869 err = btf_ext_setup_core_relos(btf_ext);
2875 btf_ext__free(btf_ext);
2879 return btf_ext;
2882 const void *btf_ext__get_raw_data(const struct btf_ext *btf_ext, __u32 *size)
2884 *size = btf_ext->data_size;
2885 return btf_ext->data;
2907 * information. If optional `struct btf_ext` representing '.BTF.ext' ELF section
3114 struct btf_ext *btf_ext;
3228 d->btf_ext = OPTS_GET(opts, btf_ext, NULL);
3288 if (!d->btf_ext)
3291 r = btf_ext_visit_str_offs(d->btf_ext, fn, ctx);
4753 if (!d->btf_ext)
4756 r = btf_ext_visit_type_ids(d->btf_ext, btf_dedup_remap_type_id, d);
4947 int btf_ext_visit_type_ids(struct btf_ext *btf_ext, type_id_visit_fn visit, void *ctx)
4953 seg = &btf_ext->func_info;
4964 seg = &btf_ext->core_relo_info;
4978 int btf_ext_visit_str_offs(struct btf_ext *btf_ext, str_off_visit_fn visit, void *ctx)
4984 seg = &btf_ext->func_info;
4991 seg = &btf_ext->line_info;
5009 seg = &btf_ext->core_relo_info;