Skip to content

Commit

Permalink
add ringbuf map example
Browse files Browse the repository at this point in the history
  • Loading branch information
spoock1024 committed Jul 19, 2023
1 parent 47887eb commit 3fd1cfc
Show file tree
Hide file tree
Showing 8 changed files with 1,919 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/ringbuf_map/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
all: build-ebpf build run

export GO111MODULE=on
export PATH := $(shell go env GOPATH)/bin:$(shell go env GOROOT)/bin:$(PATH)

build-ebpf:
mkdir -p ebpf/bin
clang -D__KERNEL__ -D__ASM_SYSREG_H \
-Wno-unused-value \
-Wno-pointer-sign \
-Wno-compare-distinct-pointer-types \
-Wunused \
-Wall \
-Werror \
-I/lib/modules/$$(uname -r)/build/include \
-I/lib/modules/$$(uname -r)/build/include/uapi \
-I/lib/modules/$$(uname -r)/build/include/generated/uapi \
-I/lib/modules/$$(uname -r)/build/arch/x86/include \
-I/lib/modules/$$(uname -r)/build/arch/x86/include/uapi \
-I/lib/modules/$$(uname -r)/build/arch/x86/include/generated \
-O2 -emit-llvm \
ebpf/main.c \
-c -o - | llc -march=bpf -filetype=obj -o ebpf/bin/probe.o
go run github.com/shuLhan/go-bindata/cmd/go-bindata -pkg main -prefix "ebpf/bin" -o "probe.go" "ebpf/bin/probe.o"


build:
go build -o bin/main .

run:
sudo bin/main
Loading

0 comments on commit 3fd1cfc

Please sign in to comment.