-
Notifications
You must be signed in to change notification settings - Fork 179
/
Makefile
93 lines (82 loc) · 2.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
CMD_CLANG ?= clang
CMD_GO ?= go
CMD_RM ?= rm
CMD_BPFTOOL ?= bpftool
ASSETS_PATH ?= user/assets
DEBUG_PRINT ?=
LINUX_ARCH = arm64
ifeq ($(DEBUG),1)
DEBUG_PRINT := -DDEBUG_PRINT
endif
BUILD_TAGS ?=
TARGET_ARCH = $(LINUX_ARCH)
ifeq ($(BUILD_TAGS),forarm)
BUILD_TAGS := -tags forarm
TARGET_ARCH = arm
endif
.PHONY: all
all: ebpf_stack ebpf_syscall ebpf_perf_mmap genbtf assets build
@echo $(shell date)
.PHONY: clean
clean:
$(CMD_RM) -f user/assets/*.d
$(CMD_RM) -f user/assets/*.o
# $(CMD_RM) -f assets/ebpf_probe.go
$(CMD_RM) -f bin/stackplz_$(TARGET_ARCH)
.PHONY: ebpf_stack
ebpf_stack:
clang \
-D__TARGET_ARCH_$(TARGET_ARCH) \
-D__MODULE_STACK \
--target=bpf \
-c \
-nostdlibinc \
-no-canonical-prefixes \
-O2 \
$(DEBUG_PRINT) \
-I libbpf/src \
-I src \
-g \
-o user/assets/stack.o \
src/stack.c
.PHONY: ebpf_syscall
ebpf_syscall:
clang \
-D__TARGET_ARCH_$(TARGET_ARCH) \
-D__MODULE_SYSCALL \
--target=bpf \
-c \
-nostdlibinc \
-no-canonical-prefixes \
-O2 \
$(DEBUG_PRINT) \
-I libbpf/src \
-I src \
-g \
-o user/assets/syscall.o \
src/syscall.c
.PHONY: ebpf_perf_mmap
ebpf_perf_mmap:
clang \
-D__TARGET_ARCH_$(TARGET_ARCH) \
--target=bpf \
-c \
-nostdlibinc \
-no-canonical-prefixes \
-O2 \
$(DEBUG_PRINT) \
-I libbpf/src \
-I src \
-g \
-o user/assets/perf_mmap.o \
src/perf_mmap.c
.PHONY: genbtf
genbtf:
cd ${ASSETS_PATH} && ./$(CMD_BPFTOOL) gen min_core_btf rock5b-5.10-f9d1b1529-arm64.btf rock5b-5.10-arm64_min.btf stack.o syscall.o
cd ${ASSETS_PATH} && ./$(CMD_BPFTOOL) gen min_core_btf a12-5.10-arm64.btf a12-5.10-arm64_min.btf stack.o syscall.o
.PHONY: assets
assets:
$(CMD_GO) run github.com/shuLhan/go-bindata/cmd/go-bindata -pkg assets -o "assets/ebpf_probe.go" $(wildcard ./user/config/config_syscall_*.json ./user/assets/*.o ./user/assets/*_min.btf ./preload_libs/*.so)
.PHONY: build
build:
GOARCH=arm64 GOOS=android CGO_ENABLED=1 CC=aarch64-linux-android29-clang $(CMD_GO) build $(BUILD_TAGS) -ldflags "-w -s -extldflags '-Wl,--hash-style=sysv'" -o bin/stackplz_$(TARGET_ARCH) .