Skip to content

Commit d54d06a

Browse files
author
Alexei Starovoitov
committed
Merge branch 'Teach libbpf to "fix up" BPF verifier log'
Andrii Nakryiko says: ==================== This patch set teaches libbpf to enhance BPF verifier log with human-readable and relevant information about failed CO-RE relocation. Patch #9 is the main one with the new logic. See relevant commit messages for some more details. All the other patches are either fixing various bugs detected while working on this feature, most prominently a bug with libbpf not handling CO-RE relocations for SEC("?...") programs, or are refactoring libbpf internals to allow for easier reuse of CO-RE relo lookup and formatting logic. ==================== Signed-off-by: Alexei Starovoitov <[email protected]>
2 parents c317ab7 + ea4128e commit d54d06a

File tree

11 files changed

+464
-97
lines changed

11 files changed

+464
-97
lines changed

tools/lib/bpf/btf.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,7 @@ static int btf_ext_setup_info(struct btf_ext *btf_ext,
26262626
const struct btf_ext_info_sec *sinfo;
26272627
struct btf_ext_info *ext_info;
26282628
__u32 info_left, record_size;
2629+
size_t sec_cnt = 0;
26292630
/* The start of the info sec (including the __u32 record_size). */
26302631
void *info;
26312632

@@ -2689,8 +2690,7 @@ static int btf_ext_setup_info(struct btf_ext *btf_ext,
26892690
return -EINVAL;
26902691
}
26912692

2692-
total_record_size = sec_hdrlen +
2693-
(__u64)num_records * record_size;
2693+
total_record_size = sec_hdrlen + (__u64)num_records * record_size;
26942694
if (info_left < total_record_size) {
26952695
pr_debug("%s section has incorrect num_records in .BTF.ext\n",
26962696
ext_sec->desc);
@@ -2699,12 +2699,14 @@ static int btf_ext_setup_info(struct btf_ext *btf_ext,
26992699

27002700
info_left -= total_record_size;
27012701
sinfo = (void *)sinfo + total_record_size;
2702+
sec_cnt++;
27022703
}
27032704

27042705
ext_info = ext_sec->ext_info;
27052706
ext_info->len = ext_sec->len - sizeof(__u32);
27062707
ext_info->rec_size = record_size;
27072708
ext_info->info = info + sizeof(__u32);
2709+
ext_info->sec_cnt = sec_cnt;
27082710

27092711
return 0;
27102712
}
@@ -2788,6 +2790,9 @@ void btf_ext__free(struct btf_ext *btf_ext)
27882790
{
27892791
if (IS_ERR_OR_NULL(btf_ext))
27902792
return;
2793+
free(btf_ext->func_info.sec_idxs);
2794+
free(btf_ext->line_info.sec_idxs);
2795+
free(btf_ext->core_relo_info.sec_idxs);
27912796
free(btf_ext->data);
27922797
free(btf_ext);
27932798
}

0 commit comments

Comments
 (0)