xref: /linux/tools/lib/bpf/btf.h (revision f79e4d5f92a129a1159c973735007d4ddc8541f3)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2018 Facebook */
3 
4 #ifndef __BPF_BTF_H
5 #define __BPF_BTF_H
6 
7 #include <linux/types.h>
8 
9 #define BTF_ELF_SEC ".BTF"
10 
11 struct btf;
12 struct btf_type;
13 
14 typedef int (*btf_print_fn_t)(const char *, ...)
15 	__attribute__((format(printf, 1, 2)));
16 
17 void btf__free(struct btf *btf);
18 struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
19 __s32 btf__find_by_name(const struct btf *btf, const char *type_name);
20 const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 id);
21 __s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
22 int btf__fd(const struct btf *btf);
23 
24 #endif
25