diff mbox series

[bpf-next,2/5] libbpf: check the kflag of type tags in btf_dump

Message ID 20250122025308.2717553-3-ihor.solodrai@pm.me (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series BTF: arbitrary __attribute__ encoding | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for bpf-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success Errors and warnings before: 0 (+0) this patch: 0 (+0)
netdev/cc_maintainers warning 8 maintainers not CCed: kpsingh@kernel.org sdf@fomichev.me jolsa@kernel.org yonghong.song@linux.dev song@kernel.org john.fastabend@gmail.com haoluo@google.com martin.lau@linux.dev
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns WARNING: line length of 99 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ihor Solodrai Jan. 22, 2025, 2:53 a.m. UTC
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@pm.me>
---
 tools/lib/bpf/btf_dump.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Alan Maguire Jan. 22, 2025, 10:57 a.m. UTC | #1
On 22/01/2025 02:53, Ihor Solodrai wrote:
> 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@pm.me>

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>

> ---
>  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);
diff mbox series

Patch

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);