On Mon, Jan 27, 2025 at 3:40 PM Ihor Solodrai <ihor.solodrai@xxxxxxxxx> wrote: > > Add the following functions to libbpf API: > * btf__add_type_attr() > * btf__add_decl_attr() > > These functions allow to add to BTF the type tags and decl tags with > info->kflag set to 1. The kflag indicates that the tag directly > encodes an __attribute__ and not a normal tag. > > See Documentation/bpf/btf.rst changes in the subsequent patch for > details on the semantics. > > Suggested-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxxxxxx> > Reviewed-by: Alan Maguire <alan.maguire@xxxxxxxxxx> > --- > tools/lib/bpf/btf.c | 86 +++++++++++++++++++++++++++++----------- > tools/lib/bpf/btf.h | 3 ++ > tools/lib/bpf/libbpf.map | 2 + > 3 files changed, 68 insertions(+), 23 deletions(-) [...] LGTM, but still messed up whitespaces, see below. Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> pw-bot: cr > diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h > index 47ee8f6ac489..4392451d634b 100644 > --- a/tools/lib/bpf/btf.h > +++ b/tools/lib/bpf/btf.h > @@ -227,6 +227,7 @@ LIBBPF_API int btf__add_volatile(struct btf *btf, int ref_type_id); > LIBBPF_API int btf__add_const(struct btf *btf, int ref_type_id); > LIBBPF_API int btf__add_restrict(struct btf *btf, int ref_type_id); > LIBBPF_API int btf__add_type_tag(struct btf *btf, const char *value, int ref_type_id); > +LIBBPF_API int btf__add_type_attr(struct btf *btf, const char *value, int ref_type_id); > > /* func and func_proto construction APIs */ > LIBBPF_API int btf__add_func(struct btf *btf, const char *name, > @@ -243,6 +244,8 @@ LIBBPF_API int btf__add_datasec_var_info(struct btf *btf, int var_type_id, > /* tag construction API */ > LIBBPF_API int btf__add_decl_tag(struct btf *btf, const char *value, int ref_type_id, > int component_idx); > +LIBBPF_API int btf__add_decl_attr(struct btf *btf, const char *value, int ref_type_id, > + int component_idx); > > struct btf_dedup_opts { > size_t sz; > diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map > index a8b2936a1646..8616e10b3c1b 100644 > --- a/tools/lib/bpf/libbpf.map > +++ b/tools/lib/bpf/libbpf.map > @@ -436,4 +436,6 @@ LIBBPF_1.6.0 { > bpf_linker__add_buf; > bpf_linker__add_fd; > bpf_linker__new_fd; > + btf__add_decl_attr; > + btf__add_type_attr; spaces here > } LIBBPF_1.5.0; > -- > 2.48.1 >