libbpf: Add generic BTF type shallow copy API
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 18 Mar 2021 19:40:29 +0000 (12:40 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 18 Mar 2021 23:14:22 +0000 (16:14 -0700)
commit9af44bc5d4d70b37c9ada24d8e0367b34b805bd3
tree1d8341986e573634611a578a49488b548f9efa82
parent90d76d3ececc74bf43b2a97f178dadfa1e52be54
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
tools/lib/bpf/btf.c
tools/lib/bpf/btf.h
tools/lib/bpf/libbpf.map