From: Andrii Nakryiko Date: Fri, 19 Mar 2021 20:59:08 +0000 (-0700) Subject: libbpf: Skip BTF fixup if object file has no BTF X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=78b226d48106fc91628f941c66545f05273269df;p=uclinux-h8%2Flinux.git libbpf: Skip BTF fixup if object file has no BTF Skip BTF fixup step when input object file is missing BTF altogether. Fixes: 8fd27bf69b86 ("libbpf: Add BPF static linker BTF and BTF.ext support") Reported-by: Jiri Olsa Signed-off-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov Tested-by: Jiri Olsa Link: https://lore.kernel.org/bpf/20210319205909.1748642-3-andrii@kernel.org --- diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index b4fff912dce2..5e0aa2f2c0ca 100644 --- a/tools/lib/bpf/linker.c +++ b/tools/lib/bpf/linker.c @@ -1313,6 +1313,9 @@ static int linker_fixup_btf(struct src_obj *obj) struct src_sec *sec; int i, j, n, m; + if (!obj->btf) + return 0; + n = btf__get_nr_types(obj->btf); for (i = 1; i <= n; i++) { struct btf_var_secinfo *vi;