at v6.3 27 lines 672 B view raw
1// SPDX-License-Identifier: GPL-2.0 2#include <linux/bpf.h> 3#include <bpf/bpf_helpers.h> 4 5struct __bpf_stdout__ { 6 __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY); 7 __type(key, int); 8 __type(value, __u32); 9 __uint(max_entries, __NR_CPUS__); 10} __bpf_stdout__ SEC(".maps"); 11 12#define puts(from) \ 13 ({ const int __len = sizeof(from); \ 14 char __from[sizeof(from)] = from; \ 15 bpf_perf_event_output(args, &__bpf_stdout__, BPF_F_CURRENT_CPU, \ 16 &__from, __len & (sizeof(from) - 1)); }) 17 18struct syscall_enter_args; 19 20SEC("raw_syscalls:sys_enter") 21int sys_enter(struct syscall_enter_args *args) 22{ 23 puts("Hello, world\n"); 24 return 0; 25} 26 27char _license[] SEC("license") = "GPL";