diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2021-03-18 20:40:29 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2021-03-19 00:14:22 +0100 |
commit | 9af44bc5d4d70b37c9ada24d8e0367b34b805bd3 (patch) | |
tree | 1d8341986e573634611a578a49488b548f9efa82 /tools/lib/bpf/btf.h | |
parent | libbpf: Extract internal set-of-strings datastructure APIs (diff) | |
download | linux-9af44bc5d4d70b37c9ada24d8e0367b34b805bd3.tar.xz linux-9af44bc5d4d70b37c9ada24d8e0367b34b805bd3.zip |
libbpf: Add generic BTF type shallow copy API
Add btf__add_type() API that performs shallow copy of a given BTF type from
the source BTF into the destination BTF. All the information and type IDs are
preserved, but all the strings encountered are added into the destination BTF
and corresponding offsets are rewritten. BTF type IDs are assumed to be
correct or such that will be (somehow) modified afterwards.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210318194036.3521577-6-andrii@kernel.org
Diffstat (limited to 'tools/lib/bpf/btf.h')
-rw-r--r-- | tools/lib/bpf/btf.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h index 029a9cfc8c2d..3b0b17ba94a1 100644 --- a/tools/lib/bpf/btf.h +++ b/tools/lib/bpf/btf.h @@ -93,6 +93,8 @@ LIBBPF_API struct btf *libbpf_find_kernel_btf(void); LIBBPF_API int btf__find_str(struct btf *btf, const char *s); LIBBPF_API int btf__add_str(struct btf *btf, const char *s); +LIBBPF_API int btf__add_type(struct btf *btf, const struct btf *src_btf, + const struct btf_type *src_type); LIBBPF_API int btf__add_int(struct btf *btf, const char *name, size_t byte_sz, int encoding); LIBBPF_API int btf__add_float(struct btf *btf, const char *name, size_t byte_sz); |