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
This program will compile and run fine on my 64 bit system, but it will fail with a relocation error on 32 bit systems:
SEC("tp/raw_syscalls/sys_enter")
intsys_enter(structtrace_event_raw_sys_enter*ctx) {
long intn=ctx->id;
bpf_printk("hello world %d", n);
return0;
}
libbpf: prog 'sys_enter': relo #0: insn #0 (LDX/ST/STX) accesses field incorrectly. Make sure you are accessing pointers, unsigned integers, or fields of matching type and size.
libbpf: prog 'sys_enter': BPF program load failed: Invalid argument
libbpf: prog 'sys_enter': -- BEGIN PROG LOAD LOG --
R1 type=ctx expected=fp
; long int n = ctx->id;
0: (85) call unknown#195896080
invalid func unknown#195896080
processed 1 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
-- END PROG LOAD LOG --
libbpf: failed to load program 'sys_enter'
libbpf: failed to load object 'bootstrap_bpf'
libbpf: failed to load BPF skeleton 'bootstrap_bpf': -22
Failed to load and verify BPF skeleton
I'm cross-compiling using a Yocto build. I've reproduced this both with arm and x86.
From my understanding, the issue comes from the long int in trace_event_raw_sys_enter, which is 64 bit in the compiled eBPF program, but 32 bit in the target kernel.
struct trace_event_raw_sys_enter {
struct trace_entry ent;
long int id;
long unsigned int args[6];
char __data[0];
} __attribute__((preserve_access_index));
Indeed, manually changing the id definition in vmlinux.h will fix the relocation error:
Q: clang flag for target bpf? hints that using a native target could help, but I guess that would completely break CORE relocations since preserve_access_index is a -target bpf-specific attribute, right?
Am I missing something? If I had to fix the issue right now I would replace all long definitions in vmlinux.h to u32 when targeting 32 bit systems. Shouldn't bpftool btf dump handle this?
We're using eBPF on embedded systems, where 32 bit is still fairly common.
Thanks.
The text was updated successfully, but these errors were encountered:
This program will compile and run fine on my 64 bit system, but it will fail with a relocation error on 32 bit systems:
I'm cross-compiling using a Yocto build. I've reproduced this both with arm and x86.
From my understanding, the issue comes from the
long int
intrace_event_raw_sys_enter
, which is 64 bit in the compiled eBPF program, but 32 bit in the target kernel.Indeed, manually changing the
id
definition invmlinux.h
will fix the relocation error:Q: clang flag for target bpf? hints that using a native target could help, but I guess that would completely break CORE relocations since
preserve_access_index
is a-target bpf
-specific attribute, right?Am I missing something? If I had to fix the issue right now I would replace all long definitions in
vmlinux.h
to u32 when targeting 32 bit systems. Shouldn'tbpftool btf dump
handle this?We're using eBPF on embedded systems, where 32 bit is still fairly common.
Thanks.
The text was updated successfully, but these errors were encountered: