Commit bd16dee6 authored by Yonghong Song's avatar Yonghong Song Committed by Alexei Starovoitov

bpf: Add BTF_KIND_DECL_TAG typedef support

The llvm patches ([1], [2]) added support to attach btf_decl_tag
attributes to typedef declarations. This patch added
support in kernel.

  [1] https://reviews.llvm.org/D110127
  [2] https://reviews.llvm.org/D112259Signed-off-by: default avatarYonghong Song <yhs@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211021195628.4018847-1-yhs@fb.com
parent a33f607f
...@@ -468,7 +468,7 @@ static bool btf_type_is_decl_tag(const struct btf_type *t) ...@@ -468,7 +468,7 @@ static bool btf_type_is_decl_tag(const struct btf_type *t)
static bool btf_type_is_decl_tag_target(const struct btf_type *t) static bool btf_type_is_decl_tag_target(const struct btf_type *t)
{ {
return btf_type_is_func(t) || btf_type_is_struct(t) || return btf_type_is_func(t) || btf_type_is_struct(t) ||
btf_type_is_var(t); btf_type_is_var(t) || btf_type_is_typedef(t);
} }
u32 btf_nr_types(const struct btf *btf) u32 btf_nr_types(const struct btf *btf)
...@@ -3885,7 +3885,7 @@ static int btf_decl_tag_resolve(struct btf_verifier_env *env, ...@@ -3885,7 +3885,7 @@ static int btf_decl_tag_resolve(struct btf_verifier_env *env,
component_idx = btf_type_decl_tag(t)->component_idx; component_idx = btf_type_decl_tag(t)->component_idx;
if (component_idx != -1) { if (component_idx != -1) {
if (btf_type_is_var(next_type)) { if (btf_type_is_var(next_type) || btf_type_is_typedef(next_type)) {
btf_verifier_log_type(env, v->t, "Invalid component_idx"); btf_verifier_log_type(env, v->t, "Invalid component_idx");
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment