Skip to content

Commit 5c07f2f

Browse files
yonghong-songAlexei Starovoitov
authored andcommitted
bpftool: Add support for BTF_KIND_TAG
Added bpftool support to dump BTF_KIND_TAG information. The new bpftool will be used in later patches to dump btf in the test bpf program object file. Currently, the tags are not emitted with bpftool btf dump file <path> format c and they are silently ignored. The tag information is mostly used in the kernel for verification purpose and the kernel uses its own btf to check. With adding these tags to vmlinux.h, tags will be encoded in program's btf but they will not be used by the kernel, at least for now. So let us delay adding these tags to format C header files until there is a real need. Signed-off-by: Yonghong Song <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 5b84bd1 commit 5c07f2f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tools/bpf/bpftool/btf.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = {
3737
[BTF_KIND_VAR] = "VAR",
3838
[BTF_KIND_DATASEC] = "DATASEC",
3939
[BTF_KIND_FLOAT] = "FLOAT",
40+
[BTF_KIND_TAG] = "TAG",
4041
};
4142

4243
struct btf_attach_table {
@@ -347,6 +348,17 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
347348
printf(" size=%u", t->size);
348349
break;
349350
}
351+
case BTF_KIND_TAG: {
352+
const struct btf_tag *tag = (const void *)(t + 1);
353+
354+
if (json_output) {
355+
jsonw_uint_field(w, "type_id", t->type);
356+
jsonw_int_field(w, "component_idx", tag->component_idx);
357+
} else {
358+
printf(" type_id=%u component_idx=%d", t->type, tag->component_idx);
359+
}
360+
break;
361+
}
350362
default:
351363
break;
352364
}

0 commit comments

Comments
 (0)