Skip to content

Commit e266ad5

Browse files
committed
libbpf: fix sym_is_subprog() logic for weak global subprogs
JIRA: https://issues.redhat.com/browse/RHEL-85485 commit 4073213 Author: Andrii Nakryiko <andrii@kernel.org> Date: Tue Oct 8 18:15:54 2024 -0700 libbpf: fix sym_is_subprog() logic for weak global subprogs sym_is_subprog() is incorrectly rejecting relocations against *weak* global subprogs. Fix that by realizing that STB_WEAK is also a global function. While it seems like verifier doesn't support taking an address of non-static subprog right now, it's still best to fix support for it on libbpf side, otherwise users will get a very confusing error during BPF skeleton generation or static linking due to misinterpreted relocation: libbpf: prog 'handle_tp': bad map relo against 'foo' in section '.text' Error: failed to open BPF object file: Relocation failed It's clearly not a map relocation, but is treated and reported as such without this fix. Fixes: 53eddb5 ("libbpf: Support subprog address relocation") Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/r/20241009011554.880168-1-andrii@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Viktor Malik <vmalik@redhat.com>
1 parent 91aaed3 commit e266ad5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3985,7 +3985,7 @@ static bool sym_is_subprog(const Elf64_Sym *sym, int text_shndx)
39853985
return true;
39863986

39873987
/* global function */
3988-
return bind == STB_GLOBAL && type == STT_FUNC;
3988+
return (bind == STB_GLOBAL || bind == STB_WEAK) && type == STT_FUNC;
39893989
}
39903990

39913991
static int find_extern_btf_id(const struct btf *btf, const char *ext_name)

0 commit comments

Comments
 (0)