* [PATCH bpf-next] libbpf: fix sym_is_subprog() logic for weak global subprogs
@ 2024-10-09 1:15 Andrii Nakryiko
2024-10-10 1:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Andrii Nakryiko @ 2024-10-09 1:15 UTC (permalink / raw)
To: bpf, ast, daniel, martin.lau; +Cc: andrii, kernel-team
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: 53eddb5e04ac ("libbpf: Support subprog address relocation")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/libbpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 712b95e8891b..05ad264ff09b 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -4013,7 +4013,7 @@ static bool sym_is_subprog(const Elf64_Sym *sym, int text_shndx)
return true;
/* global function */
- return bind == STB_GLOBAL && type == STT_FUNC;
+ return (bind == STB_GLOBAL || bind == STB_WEAK) && type == STT_FUNC;
}
static int find_extern_btf_id(const struct btf *btf, const char *ext_name)
--
2.43.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next] libbpf: fix sym_is_subprog() logic for weak global subprogs
2024-10-09 1:15 [PATCH bpf-next] libbpf: fix sym_is_subprog() logic for weak global subprogs Andrii Nakryiko
@ 2024-10-10 1:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-10 1:40 UTC (permalink / raw)
To: Andrii Nakryiko; +Cc: bpf, ast, daniel, martin.lau, kernel-team
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Tue, 8 Oct 2024 18:15:54 -0700 you wrote:
> 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:
>
> [...]
Here is the summary with links:
- [bpf-next] libbpf: fix sym_is_subprog() logic for weak global subprogs
https://git.kernel.org/bpf/bpf-next/c/4073213488be
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-10 1:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09 1:15 [PATCH bpf-next] libbpf: fix sym_is_subprog() logic for weak global subprogs Andrii Nakryiko
2024-10-10 1:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox