Skip to content

Commit

Permalink
libbpf: Skip BTF fixup if object file has no BTF
Browse files Browse the repository at this point in the history
Skip BTF fixup step when input object file is missing BTF altogether.

Fixes: 8fd27bf ("libbpf: Add BPF static linker BTF and BTF.ext support")
Reported-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/bpf/20210319205909.1748642-3-andrii@kernel.org
  • Loading branch information
Andrii Nakryiko authored and Alexei Starovoitov committed Mar 23, 2021
1 parent 9ef0528 commit 78b226d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/lib/bpf/linker.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 78b226d

Please sign in to comment.