Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libbpf: Do not resolve size on duplicate FUNCs

FUNCs do not have sizes, thus currently btf__resolve_size will fail
with -EINVAL. Add conditions so that we only update size when the BTF
object is not function or function prototype.

Signed-off-by: Eric Long <i@hack3r.moe>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241002-libbpf-dup-extern-funcs-v4-1-560eb460ff90@hack3r.moe

authored by

Eric Long and committed by
Andrii Nakryiko
4b146e95 c50fc1cb

+4
+4
tools/lib/bpf/linker.c
··· 2451 2451 if (glob_sym && glob_sym->var_idx >= 0) { 2452 2452 __s64 sz; 2453 2453 2454 + /* FUNCs don't have size, nothing to update */ 2455 + if (btf_is_func(t)) 2456 + continue; 2457 + 2454 2458 dst_var = &dst_sec->sec_vars[glob_sym->var_idx]; 2455 2459 /* Because underlying BTF type might have 2456 2460 * changed, so might its size have changed, so