From: Andrii Nakryiko <andriin@fb.com>
Date: Wed, 18 Dec 2019 16:28:36 -0800
Subject: libbpf: BTF is required when externs are present
Patch-mainline: v5.6-rc1
Git-commit: 630628cb7dc39780660d8fcedc66e0298a82f9da
References: bsc#1177028
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
Acked-by: Gary Lin <glin@suse.com>
---
tools/lib/bpf/libbpf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1830,7 +1830,8 @@ static void bpf_object__sanitize_btf_ext
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,