mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
selftests/bpf: Test linking with duplicate extern functions
Previously when multiple BPF object files referencing the same extern function (usually kfunc) are statically linked using `bpftool gen object`, libbpf tries to get the nonexistent size of BTF_KIND_FUNC_PROTO and fails. This test ensures it is fixed. Signed-off-by: Eric Long <i@hack3r.moe> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20241002-libbpf-dup-extern-funcs-v4-2-560eb460ff90@hack3r.moe
This commit is contained in:
parent
4b146e95da
commit
3c591de285
|
|
@ -63,6 +63,8 @@ extern int set_output_val2(int x);
|
|||
/* here we'll force set_output_ctx2() to be __hidden in the final obj file */
|
||||
__hidden extern void set_output_ctx2(__u64 *ctx);
|
||||
|
||||
void *bpf_cast_to_kern_ctx(void *obj) __ksym;
|
||||
|
||||
SEC("?raw_tp/sys_enter")
|
||||
int BPF_PROG(handler1, struct pt_regs *regs, long id)
|
||||
{
|
||||
|
|
@ -86,4 +88,10 @@ int BPF_PROG(handler1, struct pt_regs *regs, long id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Generate BTF FUNC record and test linking with duplicate extern functions */
|
||||
void kfunc_gen1(void)
|
||||
{
|
||||
bpf_cast_to_kern_ctx(0);
|
||||
}
|
||||
|
||||
char LICENSE[] SEC("license") = "GPL";
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ extern int set_output_val1(int x);
|
|||
/* here we'll force set_output_ctx1() to be __hidden in the final obj file */
|
||||
__hidden extern void set_output_ctx1(__u64 *ctx);
|
||||
|
||||
void *bpf_cast_to_kern_ctx(void *obj) __ksym;
|
||||
|
||||
SEC("?raw_tp/sys_enter")
|
||||
int BPF_PROG(handler2, struct pt_regs *regs, long id)
|
||||
{
|
||||
|
|
@ -86,4 +88,10 @@ int BPF_PROG(handler2, struct pt_regs *regs, long id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Generate BTF FUNC record and test linking with duplicate extern functions */
|
||||
void kfunc_gen2(void)
|
||||
{
|
||||
bpf_cast_to_kern_ctx(0);
|
||||
}
|
||||
|
||||
char LICENSE[] SEC("license") = "GPL";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user