Closed ankitmnit closed 1 year ago
Hello. I'm getting a different error in this same example. The compilation goes well, but I can't load the program.
My error is this:
bpftool prog load hello-func.bpf.o /sys/fs/bpf/hello
# libbpf: failed to guess program type from ELF section 'raw_tp'
# libbpf: supported section(type) names are: socket sk_reuseport/migrate sk_reuseport kprobe/
# uprobe/ kretprobe/ uretprobe/ classifier action tracepoint/ tp/ raw_tracepoint/ raw_tp/ tp_btf/
# fentry/ fmod_ret/ fexit/ fentry.s/ fmod_ret.s/ fexit.s/ freplace/ lsm/ lsm.s/ iter/ syscall xdp_devmap/
# xdp_cpumap/ xdp perf_event lwt_in lwt_out lwt_xmit lwt_seg6local cgroup_skb/ingress cgroup_skb/egress
# cgroup/skb cgroup/sock_create cgroup/sock_release cgroup/sock cgroup/post_bind4 cgroup/post_bind6
# cgroup/dev sockops sk_skb/stream_parser sk_skb/stream_verdict sk_skb sk_msg lirc_mode2
# flow_dissector cgroup/bind4 cgroup/bind6 cgroup/connect4 cgroup/connect6 cgroup/sendmsg4
# cgroup/sendmsg6 cgroup/recvmsg4 cgroup/recvmsg6 cgroup/getpeername4 cgroup/getpeername6
# cgroup/getsockname4 cgroup/getsockname6 cgroup/sysctl cgroup/getsockopt cgroup/setsockopt
# struct_ops sk_lookup/
Update:
I was able to fix my program by changing the SEC part:
SEC("raw_tp/")
I would recommend keeping each error to a different issue, or discussions will quickly turn into a mess. I've commented on the SEC("raw_tp/")
issue here.
As for the compilation issue, I would suggest mentioning your kernel version (uname -r
) and clang/LLVM version (clang --version
). It looks like clang cannot find the definition for the struct bpf_raw_tracepoint_args
, which is rather surprising because this struct has been in the UAPI header for a long time, since 4.17.
If your kernel is older than that, then you have your answer. Otherwise, clang probably fails to look at the right header file for some reason, and it would be helpful to add the -H
flag to the clang invocation in the Makefile to figure out what headers it's using.
@ankitmnit I was unable to reproduce the compilation issue. Did you follow all the steps in the README? Are you using the provided Lima config or something else for your virtual machine setup?
I'll close this for now, please feel free to re-open with more information if you can reproduce
It gives following error when compiling hello-func.bpf.c from chapter3