summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/prog_tests/btf_write.c
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2021-10-12 09:48:38 -0700
committerAlexei Starovoitov <ast@kernel.org>2021-10-18 18:35:36 -0700
commit223f903e9c832699f4e5f422281a60756c1c6cfe (patch)
tree3e6417cd43149323fe5c10bd25d234a82a6088dc /tools/testing/selftests/bpf/prog_tests/btf_write.c
parent431bfb9ee3e2ac0294d5ef58cee87683807299c0 (diff)
downloadlinux-223f903e9c832699f4e5f422281a60756c1c6cfe.tar.bz2
bpf: Rename BTF_KIND_TAG to BTF_KIND_DECL_TAG
Patch set [1] introduced BTF_KIND_TAG to allow tagging declarations for struct/union, struct/union field, var, func and func arguments and these tags will be encoded into dwarf. They are also encoded to btf by llvm for the bpf target. After BTF_KIND_TAG is introduced, we intended to use it for kernel __user attributes. But kernel __user is actually a type attribute. Upstream and internal discussion showed it is not a good idea to mix declaration attribute and type attribute. So we proposed to introduce btf_type_tag as a type attribute and existing btf_tag renamed to btf_decl_tag ([2]). This patch renamed BTF_KIND_TAG to BTF_KIND_DECL_TAG and some other declarations with *_tag to *_decl_tag to make it clear the tag is for declaration. In the future, BTF_KIND_TYPE_TAG might be introduced per [3]. [1] https://lore.kernel.org/bpf/20210914223004.244411-1-yhs@fb.com/ [2] https://reviews.llvm.org/D111588 [3] https://reviews.llvm.org/D111199 Fixes: b5ea834dde6b ("bpf: Support for new btf kind BTF_KIND_TAG") Fixes: 5b84bd10363e ("libbpf: Add support for BTF_KIND_TAG") Fixes: 5c07f2fec003 ("bpftool: Add support for BTF_KIND_TAG") Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20211012164838.3345699-1-yhs@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/btf_write.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/btf_write.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/btf_write.c b/tools/testing/selftests/bpf/prog_tests/btf_write.c
index 886e0fc1efb1..b912eeb0b6b4 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf_write.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf_write.c
@@ -277,26 +277,26 @@ static void gen_btf(struct btf *btf)
"[17] DATASEC 'datasec1' size=12 vlen=1\n"
"\ttype_id=1 offset=4 size=8", "raw_dump");
- /* TAG */
- id = btf__add_tag(btf, "tag1", 16, -1);
+ /* DECL_TAG */
+ id = btf__add_decl_tag(btf, "tag1", 16, -1);
ASSERT_EQ(id, 18, "tag_id");
t = btf__type_by_id(btf, 18);
ASSERT_STREQ(btf__str_by_offset(btf, t->name_off), "tag1", "tag_value");
- ASSERT_EQ(btf_kind(t), BTF_KIND_TAG, "tag_kind");
+ ASSERT_EQ(btf_kind(t), BTF_KIND_DECL_TAG, "tag_kind");
ASSERT_EQ(t->type, 16, "tag_type");
- ASSERT_EQ(btf_tag(t)->component_idx, -1, "tag_component_idx");
+ ASSERT_EQ(btf_decl_tag(t)->component_idx, -1, "tag_component_idx");
ASSERT_STREQ(btf_type_raw_dump(btf, 18),
- "[18] TAG 'tag1' type_id=16 component_idx=-1", "raw_dump");
+ "[18] DECL_TAG 'tag1' type_id=16 component_idx=-1", "raw_dump");
- id = btf__add_tag(btf, "tag2", 14, 1);
+ id = btf__add_decl_tag(btf, "tag2", 14, 1);
ASSERT_EQ(id, 19, "tag_id");
t = btf__type_by_id(btf, 19);
ASSERT_STREQ(btf__str_by_offset(btf, t->name_off), "tag2", "tag_value");
- ASSERT_EQ(btf_kind(t), BTF_KIND_TAG, "tag_kind");
+ ASSERT_EQ(btf_kind(t), BTF_KIND_DECL_TAG, "tag_kind");
ASSERT_EQ(t->type, 14, "tag_type");
- ASSERT_EQ(btf_tag(t)->component_idx, 1, "tag_component_idx");
+ ASSERT_EQ(btf_decl_tag(t)->component_idx, 1, "tag_component_idx");
ASSERT_STREQ(btf_type_raw_dump(btf, 19),
- "[19] TAG 'tag2' type_id=14 component_idx=1", "raw_dump");
+ "[19] DECL_TAG 'tag2' type_id=14 component_idx=1", "raw_dump");
}
static void test_btf_add()
@@ -336,8 +336,8 @@ static void test_btf_add()
"[16] VAR 'var1' type_id=1, linkage=global-alloc",
"[17] DATASEC 'datasec1' size=12 vlen=1\n"
"\ttype_id=1 offset=4 size=8",
- "[18] TAG 'tag1' type_id=16 component_idx=-1",
- "[19] TAG 'tag2' type_id=14 component_idx=1");
+ "[18] DECL_TAG 'tag1' type_id=16 component_idx=-1",
+ "[19] DECL_TAG 'tag2' type_id=14 component_idx=1");
btf__free(btf);
}
@@ -389,8 +389,8 @@ static void test_btf_add_btf()
"[16] VAR 'var1' type_id=1, linkage=global-alloc",
"[17] DATASEC 'datasec1' size=12 vlen=1\n"
"\ttype_id=1 offset=4 size=8",
- "[18] TAG 'tag1' type_id=16 component_idx=-1",
- "[19] TAG 'tag2' type_id=14 component_idx=1",
+ "[18] DECL_TAG 'tag1' type_id=16 component_idx=-1",
+ "[19] DECL_TAG 'tag2' type_id=14 component_idx=1",
/* types appended from the second BTF */
"[20] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED",
@@ -418,8 +418,8 @@ static void test_btf_add_btf()
"[35] VAR 'var1' type_id=20, linkage=global-alloc",
"[36] DATASEC 'datasec1' size=12 vlen=1\n"
"\ttype_id=20 offset=4 size=8",
- "[37] TAG 'tag1' type_id=35 component_idx=-1",
- "[38] TAG 'tag2' type_id=33 component_idx=1");
+ "[37] DECL_TAG 'tag1' type_id=35 component_idx=-1",
+ "[38] DECL_TAG 'tag2' type_id=33 component_idx=1");
cleanup:
btf__free(btf1);