Skip to content

Commit

Permalink
libbpf: BTF is required when externs are present
Browse files Browse the repository at this point in the history
BTF is required to get type information about extern variables.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20191219002837.3074619-4-andriin@fb.com
  • Loading branch information
Andrii Nakryiko authored and Alexei Starovoitov committed Dec 19, 2019
1 parent 8601fd4 commit 630628c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/lib/bpf/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,8 @@ static void bpf_object__sanitize_btf_ext(struct bpf_object *obj)

static bool bpf_object__is_btf_mandatory(const struct bpf_object *obj)
{
return obj->efile.btf_maps_shndx >= 0;
return obj->efile.btf_maps_shndx >= 0 ||
obj->nr_extern > 0;
}

static int bpf_object__init_btf(struct bpf_object *obj,
Expand Down

0 comments on commit 630628c

Please sign in to comment.