forked from luck/tmp_suning_uos_patched
f0fdfefb2d
The program and map iterators work similar to seq_file-s. Once the program is pinned in bpffs it can be read with "cat" tool to print human readable output. In this case about BPF programs and maps. For example: $ cat /sys/fs/bpf/progs.debug id name attached 5 dump_bpf_map bpf_iter_bpf_map 6 dump_bpf_prog bpf_iter_bpf_prog $ cat /sys/fs/bpf/maps.debug id name max_entries 3 iterator.rodata 1 To avoid kernel build dependency on clang 10 separate bpf skeleton generation into manual "make" step and instead check-in generated .skel.h into git. Unlike 'bpftool prog show' in-kernel BTF name is used (when available) to print full name of BPF program instead of 16-byte truncated name. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/20200819042759.51280-3-alexei.starovoitov@gmail.com
58 lines
1.5 KiB
Makefile
58 lines
1.5 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
OUTPUT := .output
|
|
CLANG ?= clang
|
|
LLC ?= llc
|
|
LLVM_STRIP ?= llvm-strip
|
|
DEFAULT_BPFTOOL := $(OUTPUT)/sbin/bpftool
|
|
BPFTOOL ?= $(DEFAULT_BPFTOOL)
|
|
LIBBPF_SRC := $(abspath ../../../../tools/lib/bpf)
|
|
BPFOBJ := $(OUTPUT)/libbpf.a
|
|
BPF_INCLUDE := $(OUTPUT)
|
|
INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../../../tools/lib) \
|
|
-I$(abspath ../../../../tools/include/uapi)
|
|
CFLAGS := -g -Wall
|
|
|
|
abs_out := $(abspath $(OUTPUT))
|
|
ifeq ($(V),1)
|
|
Q =
|
|
msg =
|
|
else
|
|
Q = @
|
|
msg = @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))";
|
|
MAKEFLAGS += --no-print-directory
|
|
submake_extras := feature_display=0
|
|
endif
|
|
|
|
.DELETE_ON_ERROR:
|
|
|
|
.PHONY: all clean
|
|
|
|
all: iterators.skel.h
|
|
|
|
clean:
|
|
$(call msg,CLEAN)
|
|
$(Q)rm -rf $(OUTPUT) iterators
|
|
|
|
iterators.skel.h: $(OUTPUT)/iterators.bpf.o | $(BPFTOOL)
|
|
$(call msg,GEN-SKEL,$@)
|
|
$(Q)$(BPFTOOL) gen skeleton $< > $@
|
|
|
|
|
|
$(OUTPUT)/iterators.bpf.o: iterators.bpf.c $(BPFOBJ) | $(OUTPUT)
|
|
$(call msg,BPF,$@)
|
|
$(Q)$(CLANG) -g -O2 -target bpf $(INCLUDES) \
|
|
-c $(filter %.c,$^) -o $@ && \
|
|
$(LLVM_STRIP) -g $@
|
|
|
|
$(OUTPUT):
|
|
$(call msg,MKDIR,$@)
|
|
$(Q)mkdir -p $(OUTPUT)
|
|
|
|
$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)
|
|
$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) \
|
|
OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
|
|
|
|
$(DEFAULT_BPFTOOL):
|
|
$(Q)$(MAKE) $(submake_extras) -C ../../../../tools/bpf/bpftool \
|
|
prefix= OUTPUT=$(abs_out)/ DESTDIR=$(abs_out) install
|