BPF List
 help / color / mirror / Atom feed
From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: bpf@vger.kernel.org
Cc: andrii@kernel.org, ast@kernel.org, daniel@iogearbox.net,
	eddyz87@gmail.com, mykolal@fb.com, jose.marchesi@oracle.com
Subject: [PATCH bpf-next v3 3/6] libbpf: check the kflag of type tags in btf_dump
Date: Thu, 30 Jan 2025 12:12:36 -0800	[thread overview]
Message-ID: <20250130201239.1429648-4-ihor.solodrai@linux.dev> (raw)
In-Reply-To: <20250130201239.1429648-1-ihor.solodrai@linux.dev>

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>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/lib/bpf/btf_dump.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
index a3fc6908f6c9..460c3e57fadb 100644
--- a/tools/lib/bpf/btf_dump.c
+++ b/tools/lib/bpf/btf_dump.c
@@ -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);
-- 
2.48.1


  parent reply	other threads:[~2025-01-30 20:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-30 20:12 [PATCH bpf-next v3 0/6] BTF: arbitrary __attribute__ encoding Ihor Solodrai
2025-01-30 20:12 ` [PATCH bpf-next v3 1/6] libbpf: introduce kflag for type_tags and decl_tags in BTF Ihor Solodrai
2025-01-30 20:12 ` [PATCH bpf-next v3 2/6] docs/bpf: document the semantics of BTF tags with kind_flag Ihor Solodrai
2025-01-30 20:12 ` Ihor Solodrai [this message]
2025-01-30 20:12 ` [PATCH bpf-next v3 4/6] selftests/bpf: add a btf_dump test for type_tags Ihor Solodrai
2025-01-30 20:12 ` [PATCH bpf-next v3 5/6] bpf: allow kind_flag for BTF type and decl tags Ihor Solodrai
2025-01-31  2:55   ` Eduard Zingerman
2025-01-31  3:55     ` Ihor Solodrai
2025-01-30 20:12 ` [PATCH bpf-next v3 6/6] selftests/bpf: add a BTF verification test for kflagged type_tag Ihor Solodrai
2025-02-06  1:00 ` [PATCH bpf-next v3 0/6] BTF: arbitrary __attribute__ encoding patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250130201239.1429648-4-ihor.solodrai@linux.dev \
    --to=ihor.solodrai@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=jose.marchesi@oracle.com \
    --cc=mykolal@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox