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
This commit is contained in:
Andrii Nakryiko
2021-03-18 12:40:29 -07:00
committed by Andrii Nakryiko
parent 861ad35ceb
commit 4fdc36418d
3 changed files with 51 additions and 0 deletions

View File

@@ -354,4 +354,5 @@ LIBBPF_0.3.0 {
LIBBPF_0.4.0 {
global:
btf__add_float;
btf__add_type;
} LIBBPF_0.3.0;