1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ 2 /* Copyright (c) 2018 Facebook */ 3 4 #ifndef __LIBBPF_BTF_H 5 #define __LIBBPF_BTF_H 6 7 #include <linux/types.h> 8 9 #ifndef LIBBPF_API 10 #define LIBBPF_API __attribute__((visibility("default"))) 11 #endif 12 13 #define BTF_ELF_SEC ".BTF" 14 15 struct btf; 16 struct btf_type; 17 18 typedef int (*btf_print_fn_t)(const char *, ...) 19 __attribute__((format(printf, 1, 2))); 20 21 LIBBPF_API void btf__free(struct btf *btf); 22 LIBBPF_API struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log); 23 LIBBPF_API __s32 btf__find_by_name(const struct btf *btf, 24 const char *type_name); 25 LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf, 26 __u32 id); 27 LIBBPF_API __s64 btf__resolve_size(const struct btf *btf, __u32 type_id); 28 LIBBPF_API int btf__resolve_type(const struct btf *btf, __u32 type_id); 29 LIBBPF_API int btf__fd(const struct btf *btf); 30 LIBBPF_API const char *btf__name_by_offset(const struct btf *btf, __u32 offset); 31 32 #endif /* __LIBBPF_BTF_H */ 33