diff options
-rw-r--r-- | tools/build/feature/Makefile | 4 | ||||
-rw-r--r-- | tools/build/feature/test-libbpf-btf__raw_data.c | 8 | ||||
-rw-r--r-- | tools/perf/Makefile.config | 5 | ||||
-rw-r--r-- | tools/perf/util/bpf-event.c | 4 |
4 files changed, 20 insertions, 1 deletions
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index aecb6a28a770..5b31a6d063d7 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -61,6 +61,7 @@ FILES= \ test-libbpf-bpf_prog_load.bin \ test-libbpf-bpf_object__next_program.bin \ test-libbpf-bpf_object__next_map.bin \ + test-libbpf-btf__raw_data.bin \ test-get_cpuid.bin \ test-sdt.bin \ test-cxx.bin \ @@ -303,6 +304,9 @@ $(OUTPUT)test-libbpf-bpf_object__next_program.bin: $(OUTPUT)test-libbpf-bpf_object__next_map.bin: $(BUILD) -lbpf +$(OUTPUT)test-libbpf-btf__raw_data.bin: + $(BUILD) -lbpf + $(OUTPUT)test-sdt.bin: $(BUILD) diff --git a/tools/build/feature/test-libbpf-btf__raw_data.c b/tools/build/feature/test-libbpf-btf__raw_data.c new file mode 100644 index 000000000000..57da31dd7581 --- /dev/null +++ b/tools/build/feature/test-libbpf-btf__raw_data.c @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <bpf/btf.h> + +int main(void) +{ + btf__raw_data(NULL /* btf_ro */, NULL /* size */); + return 0; +} diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index a7a80e2280bd..c27fd00865c5 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -585,6 +585,10 @@ ifndef NO_LIBELF ifeq ($(feature-libbpf-bpf_object__next_map), 1) CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP endif + $(call feature_check,libbpf-btf__raw_data) + ifeq ($(feature-libbpf-btf__raw_data), 1) + CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA + endif else dummy := $(error Error: No libbpf devel library found, please install libbpf-devel); endif @@ -593,6 +597,7 @@ ifndef NO_LIBELF CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP + CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA endif endif diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c index 91c4c5dcab7f..eee64ddb766d 100644 --- a/tools/perf/util/bpf-event.c +++ b/tools/perf/util/bpf-event.c @@ -72,7 +72,8 @@ bpf_object__next_map(const struct bpf_object *obj, const struct bpf_map *prev) } #endif -const void * __weak +#ifndef HAVE_LIBBPF_BTF__RAW_DATA +const void * btf__raw_data(const struct btf *btf_ro, __u32 *size) { #pragma GCC diagnostic push @@ -80,6 +81,7 @@ btf__raw_data(const struct btf *btf_ro, __u32 *size) return btf__get_raw_data(btf_ro, size); #pragma GCC diagnostic pop } +#endif static int snprintf_hex(char *buf, size_t size, unsigned char *data, size_t len) { |