Skip to content

Commit 4c01925

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
libbpf: Enforce 64-bitness of BTF for BPF object files
BPF object files are always targeting 64-bit BPF target architecture, so enforce that at BTF level as well. Signed-off-by: Andrii Nakryiko <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent eed7818 commit 4c01925

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,6 +2434,8 @@ static int bpf_object__init_btf(struct bpf_object *obj,
24342434
BTF_ELF_SEC, err);
24352435
goto out;
24362436
}
2437+
/* enforce 8-byte pointers for BPF-targeted BTFs */
2438+
btf__set_pointer_size(obj->btf, 8);
24372439
err = 0;
24382440
}
24392441
if (btf_ext_data) {
@@ -2542,6 +2544,8 @@ static int bpf_object__sanitize_and_load_btf(struct bpf_object *obj)
25422544
if (IS_ERR(kern_btf))
25432545
return PTR_ERR(kern_btf);
25442546

2547+
/* enforce 8-byte pointers for BPF-targeted BTFs */
2548+
btf__set_pointer_size(obj->btf, 8);
25452549
bpf_object__sanitize_btf(obj, kern_btf);
25462550
}
25472551

0 commit comments

Comments
 (0)