You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Michael Schubert e6b321d321
Merge pull request #246 from kinvolk/schu/update-readme
1 month ago
Documentation Documentation: introduce a document about object pinning 2 years ago
bcc Merge pull request #242 from itaysk/cacheprefix 2 months ago
elf Merge pull request #248 from kinvolk/mauricio/fix-closing-tracepoint-programs 1 month ago
examples add lost events channel 5 months ago
pkg Fix bpf_attr initialization 10 months ago
tests Fix compilation in older kernels 2 months ago Add 2 months ago
COPYRIGHT.txt Basic PerfMap implementation 3 years ago
LICENSE-bpf.txt Add licensing information for kernel header 2 years ago
LICENSE.txt Add initial port of bpf module impl from iomodules/hover 3 years ago README: remove the "early stage" warning 2 months ago
bpf.go Add elf support 3 years ago
bpf_test.go Fix compilation in older kernels 2 months ago Fix compilation in older kernels 2 months ago



This repository provides go bindings for the bcc framework as well as low-level routines to load and use eBPF programs from .elf files.

Input and contributions are very welcome.

We recommend vendoring gobpf and pinning its version as the API is regularly changing following bcc and Linux updates and releases.


eBPF requires a recent Linux kernel. A good feature list can be found here:

Install the latest released version of libbcc (either using a package manager or by building from source).

Building ELF Object Files

To build ELF object files for use with the elf package, you must use specific sections (SEC("...")). The following are currently supported:

  • kprobe/...
  • cgroup/skb
  • cgroup/sock
  • maps/...
  • socket...
  • tracepoint...
  • uprobe/...
  • uretprobe/...
  • xdp/...

Map definitions must correspond to bpf_map_def from the elf package. Otherwise, you will encounter an error like only one map with size 280 bytes allowed per section (check bpf_map_def).

The Cilium BPF docs contain helpful info for using clang/LLVM to compile programs into elf object files:

See tests/dummy.c for a minimal dummy and for a real world example.


Sample code can be found in the examples/ directory. Examples can be run as follows:

sudo -E go run examples/bcc/perf/perf.go


The script can be used to run the tests in rkt stage1-kvm containers on different kernel versions. To run all tests on the host system, use go test as follows:

go test -tags integration -v ./...