提交 a2683788 编写于 作者: A Andrii Nakryiko 提交者: Zheng Zengkai

libbpf: Add base BTF accessor

mainline inclusion
from mainline-5.11-rc1
commit 0cfdcd63
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0cfdcd6378071f383c900e3d8862347e2af1d1ca

-------------------------------------------------

Add ability to get base BTF. It can be also used to check if BTF is split BTF.
Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20201202065244.530571-3-andrii@kernel.org
(cherry picked from commit 0cfdcd63)
Signed-off-by: NWang Yufen <wangyufen@huawei.com>
上级 a28de89b
...@@ -433,6 +433,11 @@ __u32 btf__get_nr_types(const struct btf *btf) ...@@ -433,6 +433,11 @@ __u32 btf__get_nr_types(const struct btf *btf)
return btf->start_id + btf->nr_types - 1; return btf->start_id + btf->nr_types - 1;
} }
const struct btf *btf__base_btf(const struct btf *btf)
{
return btf->base_btf;
}
/* internal helper returning non-const pointer to a type */ /* internal helper returning non-const pointer to a type */
static struct btf_type *btf_type_by_id(struct btf *btf, __u32 type_id) static struct btf_type *btf_type_by_id(struct btf *btf, __u32 type_id)
{ {
......
...@@ -51,6 +51,7 @@ LIBBPF_API __s32 btf__find_by_name(const struct btf *btf, ...@@ -51,6 +51,7 @@ LIBBPF_API __s32 btf__find_by_name(const struct btf *btf,
LIBBPF_API __s32 btf__find_by_name_kind(const struct btf *btf, LIBBPF_API __s32 btf__find_by_name_kind(const struct btf *btf,
const char *type_name, __u32 kind); const char *type_name, __u32 kind);
LIBBPF_API __u32 btf__get_nr_types(const struct btf *btf); LIBBPF_API __u32 btf__get_nr_types(const struct btf *btf);
LIBBPF_API const struct btf *btf__base_btf(const struct btf *btf);
LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf, LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf,
__u32 id); __u32 id);
LIBBPF_API size_t btf__pointer_size(const struct btf *btf); LIBBPF_API size_t btf__pointer_size(const struct btf *btf);
......
...@@ -343,6 +343,7 @@ LIBBPF_0.2.0 { ...@@ -343,6 +343,7 @@ LIBBPF_0.2.0 {
LIBBPF_0.3.0 { LIBBPF_0.3.0 {
global: global:
btf__base_btf;
btf__parse_elf_split; btf__parse_elf_split;
btf__parse_raw_split; btf__parse_raw_split;
btf__parse_split; btf__parse_split;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册