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 49b58e11a4
Merge pull request #228 from walrobin2/xdp_flags
2 days ago
Documentation Documentation: introduce a document about object pinning 2 years ago
bcc Merge pull request #242 from itaysk/cacheprefix 3 days ago
elf Merge pull request #228 from walrobin2/xdp_flags 2 days ago
examples add lost events channel 2 months ago
pkg Fix bpf_attr initialization 8 months ago
tests Fix compilation in older kernels 2 weeks ago
COPYRIGHT.txt Basic PerfMap implementation 3 years ago
LICENSE-bpf.txt Add licensing information for kernel header 1 year ago
LICENSE.txt Add initial port of bpf module impl from iomodules/hover 3 years ago elf: XDP tests 6 months ago
bpf.go Add elf support 3 years ago
bpf_test.go Fix compilation in older kernels 2 weeks ago Fix compilation in older kernels 2 weeks ago


Build Status GoDoc

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

gobpf is at an early stage but is usable nonetheless. Input and contributions are very welcome.

We recommend vendoring gobpf and pinning its version as the API is likely to change during development.


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 ./...