1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2019 Facebook */ 3 4 #include <stdbool.h> 5 #include <linux/bpf.h> 6 #include <bpf/bpf_helpers.h> 7 8 struct s { 9 int a; 10 long long b; 11 } __attribute__((packed)); 12 13 /* .data section */ 14 int in1 = -1; 15 long long in2 = -1; 16 17 /* .bss section */ 18 char in3 = '\0'; 19 long long in4 __attribute__((aligned(64))) = 0; 20 struct s in5 = {}; 21 22 /* .rodata section */ 23 const volatile struct { 24 const int in6; 25 } in = {}; 26 27 /* .data section */ 28 int out1 = -1; 29 long long out2 = -1; 30 31 /* .bss section */ 32 char out3 = 0; 33 long long out4 = 0; 34 int out6 = 0; 35 36 extern bool CONFIG_BPF_SYSCALL __kconfig; 37 extern int LINUX_KERNEL_VERSION __kconfig; 38 bool bpf_syscall = 0; 39 int kern_ver = 0; 40 41 SEC("raw_tp/sys_enter") handler(const void * ctx)42int handler(const void *ctx) 43 { 44 static volatile struct s out5; 45 46 out1 = in1; 47 out2 = in2; 48 out3 = in3; 49 out4 = in4; 50 out5 = in5; 51 out6 = in.in6; 52 53 bpf_syscall = CONFIG_BPF_SYSCALL; 54 kern_ver = LINUX_KERNEL_VERSION; 55 56 return 0; 57 } 58 59 char _license[] SEC("license") = "GPL"; 60