You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying to replicate some tests for __weak symbols I discovered that we at pressent don't support __ksym variables, only functions.
For example, if you were to attempt to load:
extern const int bpf_prog_active __ksym;
SEC("xdp") int xdp_prog(struct xdp_md *ctx) {
int *active = (int *)bpf_per_cpu_ptr(&bpf_prog_active, bpf_get_smp_processor_id());
if (active)
return 1;
return 0;
}
It results in the following error: load BTF: data section .ksyms: expected *btf.Func, not *btf.Var: not supported, while loading with bpftool (libbpf) works fine.
What is supposed to happen is that the loader finds the address of the given kernel symbol and relocates it in the assembly.
While trying to replicate some tests for
__weak
symbols I discovered that we at pressent don't support__ksym
variables, only functions.For example, if you were to attempt to load:
It results in the following error:
load BTF: data section .ksyms: expected *btf.Func, not *btf.Var: not supported
, while loading with bpftool (libbpf) works fine.What is supposed to happen is that the loader finds the address of the given kernel symbol and relocates it in the assembly.
Initial logic was added in https://lore.kernel.org/bpf/20200619231703.738941-1-andriin@fb.com/, at that point only "typeless" variables were supported so just a memory address essentially.
In a followup patch set BTF support was added https://lore.kernel.org/bpf/20200929235049.2533242-1-haoluo@google.com/, after which structured global variables can be read from the kernel with helpers such as
bpf_this_cpu_ptr
.The text was updated successfully, but these errors were encountered: