libbpf: BTF is required when externs are present
authorAndrii Nakryiko <andriin@fb.com>
Thu, 19 Dec 2019 00:28:36 +0000 (16:28 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 19 Dec 2019 01:33:36 +0000 (17:33 -0800)
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
tools/lib/bpf/libbpf.c

index 7b74382c7977efe88c1ea56864a720a6e5a8d500..6340b81b555b867f53c26302e071716ea5c5a351 100644 (file)
@@ -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,