]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Add API that copies all BTF types from one BTF object to another
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 6 Oct 2021 05:11:05 +0000 (22:11 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 6 Oct 2021 13:35:46 +0000 (15:35 +0200)
commitac33eb42375d448410ab2e90ba84bf982902216b
tree6b057355cef8a1d277e1bdcf59ea771042a61500
parent37af94fbf8c72efbd08ed5e6c14febd83a435e1d
libbpf: Add API that copies all BTF types from one BTF object to another

Add a bulk copying api, btf__add_btf(), that speeds up and simplifies
appending entire contents of one BTF object to another one, taking care
of copying BTF type data, adjusting resulting BTF type IDs according to
their new locations in the destination BTF object, as well as copying
and deduplicating all the referenced strings and updating all the string
offsets in new BTF types as appropriate.

This API is intended to be used from tools that are generating and
otherwise manipulating BTFs generically, such as pahole. In pahole's
case, this API is useful for speeding up parallelized BTF encoding, as
it allows pahole to offload all the intricacies of BTF type copying to
libbpf and handle the parallelization aspects of the process.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Link: https://lore.kernel.org/bpf/20211006051107.17921-2-andrii@kernel.org
tools/lib/bpf/btf.c
tools/lib/bpf/btf.h
tools/lib/bpf/libbpf.map