summaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/btf.h
diff options
context:
space:
mode:
authorAndrii Nakryiko2019-05-24 20:58:57 +0200
committerAlexei Starovoitov2019-05-24 23:05:57 +0200
commite6c64855fd7ad565d87b2bd617f4a50d3bdad82f (patch)
tree0ff1cdf6a80802389327d0f990f7ee3f943f600c /tools/lib/bpf/btf.h
parentlibbpf: ensure libbpf.h is included along libbpf_internal.h (diff)
downloadkernel-qcow2-linux-e6c64855fd7ad565d87b2bd617f4a50d3bdad82f.tar.gz
kernel-qcow2-linux-e6c64855fd7ad565d87b2bd617f4a50d3bdad82f.tar.xz
kernel-qcow2-linux-e6c64855fd7ad565d87b2bd617f4a50d3bdad82f.zip
libbpf: add btf__parse_elf API to load .BTF and .BTF.ext
Loading BTF and BTF.ext from ELF file is a common need. Instead of requiring every user to re-implement it, let's provide this API from libbpf itself. It's mostly copy/paste from `bpftool btf dump` implementation, which will be switched to libbpf's version in next patch. btf__parse_elf allows to load BTF and optionally BTF.ext. This is also useful for tests that need to load/work with BTF, loaded from test ELF files. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/lib/bpf/btf.h')
-rw-r--r--tools/lib/bpf/btf.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
index c7b399e81fce..bded210df9e8 100644
--- a/tools/lib/bpf/btf.h
+++ b/tools/lib/bpf/btf.h
@@ -59,6 +59,8 @@ struct btf_ext_header {
LIBBPF_API void btf__free(struct btf *btf);
LIBBPF_API struct btf *btf__new(__u8 *data, __u32 size);
+LIBBPF_API struct btf *btf__parse_elf(const char *path,
+ struct btf_ext **btf_ext);
LIBBPF_API int btf__finalize_data(struct bpf_object *obj, struct btf *btf);
LIBBPF_API int btf__load(struct btf *btf);
LIBBPF_API __s32 btf__find_by_name(const struct btf *btf,