Skip to content

byteshiva/libbpfgo-beginners

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libbpfgo-beginners

Basic eBPF examples in Golang using libbpfgo.

Install Go

See the Go documentation

Install packages

sudo apt-get update
sudo apt-get install libbpf-dev make clang llvm libelf-dev

Building and running hello

make all
sudo ./hello

This builds two things:

  • dist/hello.bpf.o - an object file for the eBPF program
  • hello - a Go executable

The Go executable reads in the object file at runtime. Take a look at the .o file with readelf if you want to see the sections defined in it.

Notes

I'm using Ubuntu 20.10, kernel 5.8, go 1.15

This approach installs the libbpf-dev package. Another alternative (which is what Tracee does) is to install the libbpf source as a git submodule, build it from source and install it to the expected location (e.g. /usr/lib/x86_64-linux-gnu/libbpf.a on an Intel x86 processor).

About

Basic eBPF examples in Golang using libbpfgo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 51.6%
  • Go 33.1%
  • Makefile 15.3%