summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/build/Makefile.feature1
-rw-r--r--tools/build/feature/Makefile4
-rw-r--r--tools/build/feature/test-libbpf-bpf_object__next_program.c8
-rw-r--r--tools/perf/Makefile.config5
-rw-r--r--tools/perf/util/bpf-event.c4
5 files changed, 21 insertions, 1 deletions
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index fa5f7b7d722c..64f8cfa6c9af 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -100,6 +100,7 @@ FEATURE_TESTS_EXTRA := \
libbpf \
libbpf-btf__load_from_kernel_by_id \
libbpf-bpf_prog_load \
+ libbpf-bpf_object__next_program \
libpfm4 \
libdebuginfod \
clang-bpf-co-re
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index b3fdcc6c5dd7..6eb829704cb9 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -59,6 +59,7 @@ FILES= \
test-libbpf.bin \
test-libbpf-btf__load_from_kernel_by_id.bin \
test-libbpf-bpf_prog_load.bin \
+ test-libbpf-bpf_object__next_program.bin \
test-get_cpuid.bin \
test-sdt.bin \
test-cxx.bin \
@@ -295,6 +296,9 @@ $(OUTPUT)test-libbpf-btf__load_from_kernel_by_id.bin:
$(OUTPUT)test-libbpf-bpf_prog_load.bin:
$(BUILD) -lbpf
+$(OUTPUT)test-libbpf-bpf_object__next_program.bin:
+ $(BUILD) -lbpf
+
$(OUTPUT)test-sdt.bin:
$(BUILD)
diff --git a/tools/build/feature/test-libbpf-bpf_object__next_program.c b/tools/build/feature/test-libbpf-bpf_object__next_program.c
new file mode 100644
index 000000000000..8bf4fd26b545
--- /dev/null
+++ b/tools/build/feature/test-libbpf-bpf_object__next_program.c
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <bpf/libbpf.h>
+
+int main(void)
+{
+ bpf_object__next_program(NULL /* obj */, NULL /* prev */);
+ return 0;
+}
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 63c92fdb1df4..046e10f65ae7 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -577,12 +577,17 @@ ifndef NO_LIBELF
ifeq ($(feature-libbpf-bpf_prog_load), 1)
CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
endif
+ $(call feature_check,libbpf-bpf_object__next_program)
+ ifeq ($(feature-libbpf-bpf_object__next_program), 1)
+ CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
+ endif
else
dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
endif
else
CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
+ CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
endif
endif
diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index 289bb55aede1..c68d88ca1ece 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -50,7 +50,8 @@ int bpf_prog_load(enum bpf_prog_type prog_type,
}
#endif
-struct bpf_program * __weak
+#ifndef HAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
+struct bpf_program *
bpf_object__next_program(const struct bpf_object *obj, struct bpf_program *prev)
{
#pragma GCC diagnostic push
@@ -58,6 +59,7 @@ bpf_object__next_program(const struct bpf_object *obj, struct bpf_program *prev)
return bpf_program__next(prev, obj);
#pragma GCC diagnostic pop
}
+#endif
struct bpf_map * __weak
bpf_object__next_map(const struct bpf_object *obj, const struct bpf_map *prev)