Commit a5f53b1d authored by Jiri Olsa's avatar Jiri Olsa Committed by Alexei Starovoitov

tools resolve_btfids: Add support for set symbols

The set symbol does not have the unique number suffix,
so we need to give it a special parsing function.

This was omitted in the first batch, because there was
no set support yet, so it slipped in the testing.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200825192124.710397-3-jolsa@kernel.org
parent 193a983c
...@@ -227,6 +227,24 @@ static char *get_id(const char *prefix_end) ...@@ -227,6 +227,24 @@ static char *get_id(const char *prefix_end)
return id; return id;
} }
static struct btf_id *add_set(struct object *obj, char *name)
{
/*
* __BTF_ID__set__name
* name = ^
* id = ^
*/
char *id = name + sizeof(BTF_SET "__") - 1;
int len = strlen(name);
if (id >= name + len) {
pr_err("FAILED to parse set name: %s\n", name);
return NULL;
}
return btf_id__add(&obj->sets, id, true);
}
static struct btf_id *add_symbol(struct rb_root *root, char *name, size_t size) static struct btf_id *add_symbol(struct rb_root *root, char *name, size_t size)
{ {
char *id; char *id;
...@@ -383,7 +401,7 @@ static int symbols_collect(struct object *obj) ...@@ -383,7 +401,7 @@ static int symbols_collect(struct object *obj)
id = add_symbol(&obj->funcs, prefix, sizeof(BTF_FUNC) - 1); id = add_symbol(&obj->funcs, prefix, sizeof(BTF_FUNC) - 1);
/* set */ /* set */
} else if (!strncmp(prefix, BTF_SET, sizeof(BTF_SET) - 1)) { } else if (!strncmp(prefix, BTF_SET, sizeof(BTF_SET) - 1)) {
id = add_symbol(&obj->sets, prefix, sizeof(BTF_SET) - 1); id = add_set(obj, prefix);
/* /*
* SET objects store list's count, which is encoded * SET objects store list's count, which is encoded
* in symbol's size, together with 'cnt' field hence * in symbol's size, together with 'cnt' field hence
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment