Linux Perf
llvm-src-prologue.c
Go to the documentation of this file.
1 #include <tests/llvm.h>
3 "/*\n"
4 " * bpf-script-test-prologue.c\n"
5 " * Test BPF prologue\n"
6 " */\n"
7 "#ifndef LINUX_VERSION_CODE\n"
8 "# error Need LINUX_VERSION_CODE\n"
9 "# error Example: for 4.2 kernel, put 'clang-opt=\"-DLINUX_VERSION_CODE=0x40200\" into llvm section of ~/.perfconfig'\n"
10 "#endif\n"
11 "#define SEC(NAME) __attribute__((section(NAME), used))\n"
12 "\n"
13 "#include <uapi/linux/fs.h>\n"
14 "\n"
15 "#define FMODE_READ 0x1\n"
16 "#define FMODE_WRITE 0x2\n"
17 "\n"
18 "static void (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) =\n"
19 " (void *) 6;\n"
20 "\n"
21 "SEC(\"func=null_lseek file->f_mode offset orig\")\n"
22 "int bpf_func__null_lseek(void *ctx, int err, unsigned long f_mode,\n"
23 " unsigned long offset, unsigned long orig)\n"
24 "{\n"
25 " if (err)\n"
26 " return 0;\n"
27 " if (f_mode & FMODE_WRITE)\n"
28 " return 0;\n"
29 " if (offset & 1)\n"
30 " return 0;\n"
31 " if (orig == SEEK_CUR)\n"
32 " return 0;\n"
33 " return 1;\n"
34 "}\n"
35 "\n"
36 "char _license[] SEC(\"license\") = \"GPL\";\n"
37 "int _version SEC(\"version\") = LINUX_VERSION_CODE;\n"
38 ;
const char test_llvm__bpf_test_prologue_prog[]