编译过程 安装llvm-10,clang-10 apt-install llvm-10 clang-10 下载bpf2go 1 go install github.com/cilium/ebpf/cmd/bpf2go@latest 修改bpf程序的include 1 #include "common.h" 编译时将bpd的headers包含进来 1 GOPACKAGE=main bpf2go -cc clang-10 -cflags '-O2 -g -Wall -Werror' -target bpfel,bpfeb bpf helloworld.bpf.c -- -I /root/ebpf/examples/headers 得到大端和小端两个版本的ELF文件,之后在go程序里加载即可。cpu一般都是小端。 内核版本要求 经测……

阅读全文