GithubHelp home page GithubHelp logo

doytsujin / libbpfgo-beginners Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lizrice/libbpfgo-beginners

0.0 1.0 0.0 28 KB

Basic eBPF examples in Golang using libbpfgo

License: Apache License 2.0

Makefile 12.68% C 42.85% Go 27.44% Dockerfile 17.02%

libbpfgo-beginners's Introduction

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.

Docker

To avoid compatibility issues, you can use the Dockerfile provided in this repository.

Build it by your own:

docker build -t hello .

And the run it from the project directory to compile the program:

docker run --rm -v $(pwd)/:/app/:z hello

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

libbpfgo-beginners's People

Contributors

lizrice avatar binchenx avatar alegrey91 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.