Skip to content

Commit 3345193

Browse files
kkdwivedianakryiko
authored andcommitted
tools/resolve_btfids: Skip unresolved symbol warning for empty BTF sets
resolve_btfids prints a warning when it finds an unresolved symbol, (id == 0) in id_patch. This can be the case for BTF sets that are empty (due to disabled config options), hence printing warnings for certain builds, most recently seen in [0]. The reason behind this is because id->cnt aliases id->id in btf_id struct, leading to empty set showing up as ID 0 when we get to id_patch, which triggers the warning. Since sets are an exception here, accomodate by reusing hole in btf_id for bool is_set member, setting it to true for BTF set when setting id->cnt, and use that to skip extraneous warning. [0]: https://lore.kernel.org/all/[email protected] Before: ; ./tools/bpf/resolve_btfids/resolve_btfids -v -b vmlinux net/ipv4/tcp_cubic.ko adding symbol tcp_cubic_kfunc_ids WARN: resolve_btfids: unresolved symbol tcp_cubic_kfunc_ids patching addr 0: ID 0 [tcp_cubic_kfunc_ids] sorting addr 4: cnt 0 [tcp_cubic_kfunc_ids] update ok for net/ipv4/tcp_cubic.ko After: ; ./tools/bpf/resolve_btfids/resolve_btfids -v -b vmlinux net/ipv4/tcp_cubic.ko adding symbol tcp_cubic_kfunc_ids patching addr 0: ID 0 [tcp_cubic_kfunc_ids] sorting addr 4: cnt 0 [tcp_cubic_kfunc_ids] update ok for net/ipv4/tcp_cubic.ko Fixes: 0e32dfc ("bpf: Enable TCP congestion control kfunc from modules") Reported-by: Pavel Skripkin <[email protected]> Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Song Liu <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent b12f031 commit 3345193

File tree

1 file changed

+5
-3
lines changed
  • tools/bpf/resolve_btfids

1 file changed

+5
-3
lines changed

tools/bpf/resolve_btfids/main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct btf_id {
8383
int cnt;
8484
};
8585
int addr_cnt;
86+
bool is_set;
8687
Elf64_Addr addr[ADDR_CNT];
8788
};
8889

@@ -451,8 +452,10 @@ static int symbols_collect(struct object *obj)
451452
* in symbol's size, together with 'cnt' field hence
452453
* that - 1.
453454
*/
454-
if (id)
455+
if (id) {
455456
id->cnt = sym.st_size / sizeof(int) - 1;
457+
id->is_set = true;
458+
}
456459
} else {
457460
pr_err("FAILED unsupported prefix %s\n", prefix);
458461
return -1;
@@ -568,9 +571,8 @@ static int id_patch(struct object *obj, struct btf_id *id)
568571
int *ptr = data->d_buf;
569572
int i;
570573

571-
if (!id->id) {
574+
if (!id->id && !id->is_set)
572575
pr_err("WARN: resolve_btfids: unresolved symbol %s\n", id->name);
573-
}
574576

575577
for (i = 0; i < id->addr_cnt; i++) {
576578
unsigned long addr = id->addr[i];

0 commit comments

Comments
 (0)