]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
libbpf: Check the kflag of type tags in btf_dump
authorIhor Solodrai <ihor.solodrai@linux.dev>
Thu, 30 Jan 2025 20:12:36 +0000 (12:12 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 6 Feb 2025 00:17:59 +0000 (16:17 -0800)
If the kflag is set for a BTF type tag, then the tag represents an
arbitrary __attribute__. Change btf_dump accordingly.

Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250130201239.1429648-4-ihor.solodrai@linux.dev
tools/lib/bpf/btf_dump.c

index a3fc6908f6c936b9cd50bfd473486ff8d63101f9..460c3e57fadb6420ab287dd1a15b1d3297c6bd29 100644 (file)
@@ -1494,7 +1494,10 @@ static void btf_dump_emit_type_chain(struct btf_dump *d,
                case BTF_KIND_TYPE_TAG:
                        btf_dump_emit_mods(d, decls);
                        name = btf_name_of(d, t->name_off);
-                       btf_dump_printf(d, " __attribute__((btf_type_tag(\"%s\")))", name);
+                       if (btf_kflag(t))
+                               btf_dump_printf(d, " __attribute__((%s))", name);
+                       else
+                               btf_dump_printf(d, " __attribute__((btf_type_tag(\"%s\")))", name);
                        break;
                case BTF_KIND_ARRAY: {
                        const struct btf_array *a = btf_array(t);