Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to get EHDR from /sys/kernel/btf/vmlinux when compiling examples #1

Open
mtcherni95 opened this issue Feb 7, 2022 · 1 comment

Comments

@mtcherni95
Copy link

Hello! First of all, by having a look at README, this tool looks so cool!

I am following the instructions to compile the examples under examples/src.
I generated libBPFCov.so. My bpftool version is v5.4.162. When running make I get:

make: command: Command not found
  MKDIR    vmlinux/
  VMLINUX  vmlinux/vmlinux.h
libbpf: failed to get EHDR from /sys/kernel/btf/vmlinux
Error: failed to load BTF from /sys/kernel/btf/vmlinux: Unknown error -4001
make: *** [Makefile:77: /home/ubuntu/dev/bpfcov/examples/src/.output/vmlinux/vmlinux.h] Error 95
make: *** Deleting file '/home/ubuntu/dev/bpfcov/examples/src/.output/vmlinux/vmlinux.h'

Apart from the Command not found error, looks like I cannot get EHDR from the vm "embedded" btf.
My machine is:
Linux 5.11.0-1025-aws #27~20.04.1-Ubuntu SMP Fri Jan 7 13:09:56 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Also, I tried to use bpftool with version 5.11.22, however it doesn't have the "skeleton" feature:

bpftool version -j
{"version":"5.11.22","features":{"libbfd":false,"skeletons":false}}

Might be that v5.4.162, does not support skeleton as well. However I do not get such an indication from Makefile.
My gut feeling is that the issue is with bpftool version. However, version 5.11.22 looks like the most updated for my OS, and if this one does not work, do you know which version might support skeleton feature? Or maybe, the problem might not be related to bpftool version.
Thank you!

@leodido
Copy link
Contributor

leodido commented Feb 8, 2022

Your gut feeling matches mine, too :)

The bpftool you need for compiling the examples' skeletons MUST have the skeletons feature (see link).

Can you try compiling a bpftool with skeletons feature and put it in the examples/tools directory?
This way the Makefile would use it rather than symlinking your system one.

I usually compile it myself from kernel sources (see here, and the BUILD_BPF_SKELS in the bpftool Makefile).

Also when running the examples Makefile, I suggest you run it with verbosity on so you can see what's actually executing.
Like so: make V=1 ....

Let me know how it goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants