Skip to content

Commit dd8e4ea

Browse files
committed
perf bpf: Add bpf.h to be used in eBPF proggies
So, the first helper is the one shortening a variable/function section attribute, from, for instance: char _license[] __attribute__((section("license"), used)) = "GPL"; to: char _license[] SEC("license") = "GPL"; Convert empty.c to that and it becomes: # cat ~acme/lib/examples/perf/bpf/empty.c #include <bpf.h> char _license[] SEC("license") = "GPL"; int _version SEC("version") = LINUX_VERSION_CODE; # Cc: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Wang Nan <[email protected]> Link: https://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 8f12a2f commit dd8e4ea

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

tools/perf/Makefile.perf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ endif
770770
ifndef NO_LIBBPF
771771
$(call QUIET_INSTALL, lib) \
772772
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'
773+
$(INSTALL) include/bpf/*.h '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'
773774
$(call QUIET_INSTALL, lib) \
774775
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'
775776
$(INSTALL) examples/bpf/*.c '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'

tools/perf/examples/bpf/empty.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
char _license[] __attribute__((section("license"), used)) = "GPL";
2-
int _version __attribute__((section("version"), used)) = LINUX_VERSION_CODE;
1+
#include <bpf.h>
2+
3+
char _license[] SEC("license") = "GPL";
4+
int _version SEC("version") = LINUX_VERSION_CODE;

tools/perf/include/bpf/bpf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#ifndef _PERF_BPF_H
3+
#define _PERF_BPF_H
4+
#define SEC(NAME) __attribute__((section(NAME), used))
5+
#endif /* _PERF_BPF_H */

0 commit comments

Comments
 (0)