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
// loading objects: field UretprobeBashReadline: program uretprobe_bash_readline: map .rodata: map create: read- and write-only maps not supported (requires >= v5.2)constvolatileu64target_pid=0;
// loading objects: field UretprobeBashReadline: program uretprobe_bash_readline: load program without BTF: invalid argument: unrecognized bpf_ld_imm64 insn//u64 target_pid = 0;
### Aglobalvariablewithconstcode:
```c
const volatile u64 target_pid = 0;
...
SEC("uretprobe/bash_readline")
int uretprobe_bash_readline(struct pt_regs *ctx) {
......
if (target_pid != 0 && target_pid != pid) {
return 0;
}
......
}
Error info
loading objects: field UretprobeBashReadline: program uretprobe_bash_readline: map .rodata: map create: read- and write-only maps not supported (requires >= v5.2)
ELF section info
[root@cnxc-ebpf no-btf-load-failed]# llvm-objdump -dj .rodata bpf_bpfeb.o
bpf_bpfeb.o: file format elf64-bpf
Disassembly of section .rodata:
0000000000000000 <target_pid>:
...
loading objects: field UretprobeBashReadline: program uretprobe_bash_readline: load program without BTF: invalid argument: unrecognized bpf_ld_imm64 insn
ELF section info
[root@cnxc-ebpf no-btf-load-failed]# llvm-objdump -dj .bss bpf_bpfeb.o
bpf_bpfeb.o: file format elf64-bpf
Disassembly of section .bss:
0000000000000000 <target_pid>:
...
0000000000000008 <unused>:
...
environment
cilium/ebpf version
0.8.1
OS version
[root@cnxc-ebpf ~]# go version
go version go1.17.8 linux/amd64
[root@cnxc-ebpf ~]# uname -a
Linux cnxc-ebpf 4.18.0-80.11.2.el8_0.x86_64 #1 SMP Tue Sep 24 11:32:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@cnxc-ebpf ~]# cat /etc/issue\S
Kernel \r on an \m
[root@cnxc-ebpf ~]# clang --version
clang version 13.0.0 (Red Hat 13.0.0-3.module_el8.6.0+1074+380cef3f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Expected behavior
It works with global variable in ebpf kernel function on linux kernel 4.18.
varhaveMapMutabilityModifiers=internal.FeatureTest("read- and write-only maps", "5.2", func() bool {
// This checks BPF_F_RDONLY_PROG and BPF_F_WRONLY_PROG. Since// BPF_MAP_FREEZE appeared in 5.2 as well we don't do a separate check.m, err:=bpfMapCreate(&bpfMapCreateAttr{
mapType: Array,
keySize: 4,
valueSize: 4,
maxEntries: 1,
flags: unix.BPF_F_RDONLY_PROG,
})
iferr!=nil {
returnfalse
}
_=m.Close()
returntrue
})
read- and write-only maps not supported (requires >= v5.2)
The map in question here is .rodata, which is generated by the compiler if you add constants to your code. As the error message says, it's not supported on your kernel.
Unless I'm missing something this is not a bug, it's a limitation of your environment. Feel free to reopen if you disagree.
Describe the bug
cant load ebpf bytecode with cilium/ebpf library on linux kernel 4.18.0 .
To Reproduce
change this code between L19 and L22
via:
uretprobe.c#L18-L22
Error info
ELF section info
B global variable with normal defined
code:
Error info
ELF section info
environment
cilium/ebpf version
0.8.1
OS version
Expected behavior
It works with global variable in ebpf kernel function on linux kernel 4.18.
Question
haveMapMutabilityModifiers
function added at f5942f5215490ef5f1bc2072f2c925ce7712a20eand can we have an other way to do this?
Others
libpf :libbpf: Load global data maps lazily on legacy kernels
issue : libbpf 1.0: support multiple .rodata*, .data*, .bss* sections #274
conclusion
I think that cilium/ebpf need to do like libbpf to load ebpf bytecode on older kernel.
and I'll keep tracing later for more detail,and send a PR for it if it is a bug.
The text was updated successfully, but these errors were encountered: