libbpf: Add base BTF accessor
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 2 Dec 2020 06:52:42 +0000 (22:52 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 3 Dec 2020 18:17:26 +0000 (10:17 -0800)
Add ability to get base BTF. It can be also used to check if BTF is split BTF.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20201202065244.530571-3-andrii@kernel.org
tools/lib/bpf/btf.c
tools/lib/bpf/btf.h
tools/lib/bpf/libbpf.map

index 8ff46cd30ca156a18c3517a8a1b58910ae39f70b..1935e83d309c40fe4c72f01d77331c7e863d9f8f 100644 (file)
@@ -432,6 +432,11 @@ __u32 btf__get_nr_types(const struct btf *btf)
        return btf->start_id + btf->nr_types - 1;
 }
 
+const struct btf *btf__base_btf(const struct btf *btf)
+{
+       return btf->base_btf;
+}
+
 /* internal helper returning non-const pointer to a type */
 static struct btf_type *btf_type_by_id(struct btf *btf, __u32 type_id)
 {
index 1093f6fe6800ddff3d4fc8150958c02a611c080f..1237bcd1dd17e0af5b1fe5cfb2118cb6ef808c34 100644 (file)
@@ -51,6 +51,7 @@ LIBBPF_API __s32 btf__find_by_name(const struct btf *btf,
 LIBBPF_API __s32 btf__find_by_name_kind(const struct btf *btf,
                                        const char *type_name, __u32 kind);
 LIBBPF_API __u32 btf__get_nr_types(const struct btf *btf);
+LIBBPF_API const struct btf *btf__base_btf(const struct btf *btf);
 LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf,
                                                  __u32 id);
 LIBBPF_API size_t btf__pointer_size(const struct btf *btf);
index 29ff4807b9094fd80a76ddbee00454944784723c..ed55498c41220d6541a96ee3e8d4cd32f7c16320 100644 (file)
@@ -340,6 +340,7 @@ LIBBPF_0.2.0 {
 
 LIBBPF_0.3.0 {
        global:
+               btf__base_btf;
                btf__parse_elf_split;
                btf__parse_raw_split;
                btf__parse_split;