libbpf-bootstrap: [Android] Failed to find valid kernel BTF
Device: Android 13 AOSP for x86_64, all necessary flags are enabled during kernel build, including CONFIG_DEBUG_INFO_BTF
bpftool version: not sure, provided by xmake-repo
libbpf: 432a4348579e0049af45c6712a2c1430f607b086
> file /sys/kernel/btf/vmlinux
/sys/kernel/btf/vmlinux : data
Steps:
git clone --recurse-submodules https://github.com/libbpf/libbpf-bootstrap
...
xmake f -p android -a x86_64 -c --require-bpftool=y
xmake -y
all compiles successfully.
minimal works on the devices.
bootstrap fails:
libbpf: failed to find valid kernel BTF
libbpf: Error loading vmlinux BTF: -3
libbpf: failed to load object 'bootstrap_bpf'
libbpf: failed to load BPF skeleton 'bootstrap_bpf': -3
Failed to load and verify BPF skeleton
My guess is that the problem is related to maps since minimal doesn’t contain any and it works.
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 19 (8 by maintainers)
Commits related to this issue
- libbpf: fix faccessat() usage on Android Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0]), this leads to ridiculous issue with libbpf refusing to load ... — committed to kernel-patches/bpf-rc by anakryiko 5 months ago
- libbpf: fix faccessat() usage on Android Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0]), this leads to ridiculous issue with libbpf refusing to load ... — committed to kernel-patches/bpf by anakryiko 5 months ago
- libbpf: fix faccessat() usage on Android Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0]), this leads to ridiculous issue with libbpf refusing to load ... — committed to kernel-patches/bpf by anakryiko 5 months ago
- libbpf: fix faccessat() usage on Android Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0]), this leads to ridiculous issue with libbpf refusing to load ... — committed to kernel-patches/bpf-rc by anakryiko 5 months ago
- libbpf: fix faccessat() usage on Android Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0]), this leads to ridiculous issue with libbpf refusing to load ... — committed to kernel-patches/bpf-rc by anakryiko 5 months ago
- libbpf: fix faccessat() usage on Android Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0]), this leads to ridiculous issue with libbpf refusing to load ... — committed to kernel-patches/bpf-rc by anakryiko 5 months ago
- libbpf: fix faccessat() usage on Android Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0]), this leads to ridiculous issue with libbpf refusing to load ... — committed to kernel-patches/bpf by anakryiko 5 months ago
- libbpf: Fix faccessat() usage on Android Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0]), this leads to ridiculous issue with libbpf refusing to load ... — committed to kernel-patches/bpf-rc by anakryiko 5 months ago
- libbpf: Fix faccessat() usage on Android Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0]), this leads to ridiculous issue with libbpf refusing to load ... — committed to anakryiko/libbpf by anakryiko 5 months ago
- libbpf: Fix faccessat() usage on Android Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0]), this leads to ridiculous issue with libbpf refusing to load ... — committed to libbpf/libbpf by anakryiko 5 months ago
- libbpf: update to latest upstream version Pull in latest libbpf upstream version that contains a fix for file access checks on Android ([0]). [0] 830e0d017bb1 ("libbpf: Fix faccessat() usage on An... — committed to anakryiko/libbpf-bootstrap by anakryiko 5 months ago
- libbpf: update to latest upstream version Pull in latest libbpf upstream version that contains a fix for file access checks on Android ([0]) and fixes memfd_create() usage ([1]). [0] 830e0d017bb1 ... — committed to anakryiko/libbpf-bootstrap by anakryiko 5 months ago
- libbpf: update to latest upstream version Pull in latest libbpf upstream version that contains a fix for file access checks on Android ([0]) and fixes memfd_create() usage ([1]). [0] 830e0d017bb1 ... — committed to libbpf/libbpf-bootstrap by anakryiko 5 months ago
- libbpf: Fix faccessat() usage on Android [ Upstream commit ad57654053805bf9a62602aaec74cc78edb6f235 ] Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0])... — committed to mj22226/linux by anakryiko 5 months ago
- libbpf: Fix faccessat() usage on Android [ Upstream commit ad57654053805bf9a62602aaec74cc78edb6f235 ] Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0])... — committed to mj22226/linux by anakryiko 5 months ago
- libbpf: Fix faccessat() usage on Android [ Upstream commit ad57654053805bf9a62602aaec74cc78edb6f235 ] Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0])... — committed to linux-ia64/linux-stable-rc by anakryiko 5 months ago
- libbpf: Fix faccessat() usage on Android [ Upstream commit ad57654053805bf9a62602aaec74cc78edb6f235 ] Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0])... — committed to linux-ia64/linux-stable-rc by anakryiko 5 months ago
- libbpf: Fix faccessat() usage on Android [ Upstream commit ad57654053805bf9a62602aaec74cc78edb6f235 ] Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0])... — committed to mj22226/linux by anakryiko 5 months ago
- libbpf: Fix faccessat() usage on Android [ Upstream commit ad57654053805bf9a62602aaec74cc78edb6f235 ] Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0])... — committed to mj22226/linux by anakryiko 5 months ago
- libbpf: Fix faccessat() usage on Android [ Upstream commit ad57654053805bf9a62602aaec74cc78edb6f235 ] Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0])... — committed to linux-ia64/linux-stable-rc by anakryiko 5 months ago
I also encountered this problem when I updated the libbpfv1.0.0 used on my Android device to the latest version a few days ago. I found that the permission check was modified in this commit: https://github.com/libbpf/libbpf/commit/9da0dcb62149ab0a6c5711813d77a844ec6f393b However, the “AT_EACCESS” flag is not supported on Android devices. Relevant instructions can be found in the AOSP source code: https://android.googlesource.com/platform/bionic/+/refs/heads/android13-release/libc/bionic/faccessat.cpp#50 Therefore, if you want to use BTF on Android devices, you can try to modify the libbpf source code and change the “AT_EACCESS” flag to 0, or you can use the pre-commit version of libbpf that modified the permission check.
If you have
/sys/kernel/btf/vmlinuxand libbpf still complains about “failed to find valid kernel BTF”, then one of two things: either your application doesn’t have permissions to open that file, or it has BTF that your version of libbpf doesn’t understand (e.g., it’s using some new BTF features that older libbpf doesn’t know how to parse). There is a slight chance that /sys/kernel/btf/vmlinux is just corrupted, you should be able to validate somewhat by dumping it using bpftool:you need add version to https://github.com/xmake-io/xmake-repo/blob/f97b2f979f870b51ca1ef7a306fe1458625d1448/packages/l/linux-tools/xmake.lua#L13
then add version in https://github.com/libbpf/libbpf-bootstrap/blob/6aa0c77287e2c6152f679013a2cf94a2d0314f72/examples/c/xmake.lua#L46
add_requires("linux-tool 5.16.9", ...)