4 " * bpf-script-test-relocation.c\n" 5 " * Test BPF loader checking relocation\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" 12 "#define BPF_MAP_TYPE_ARRAY 2\n" 13 "#define BPF_FUNC_map_lookup_elem 1\n" 14 "#define BPF_FUNC_map_update_elem 2\n" 16 "static void *(*bpf_map_lookup_elem)(void *map, void *key) =\n" 17 " (void *) BPF_FUNC_map_lookup_elem;\n" 18 "static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) =\n" 19 " (void *) BPF_FUNC_map_update_elem;\n" 21 "struct bpf_map_def {\n" 22 " unsigned int type;\n" 23 " unsigned int key_size;\n" 24 " unsigned int value_size;\n" 25 " unsigned int max_entries;\n" 28 "#define SEC(NAME) __attribute__((section(NAME), used))\n" 29 "struct bpf_map_def SEC(\"maps\") my_table = {\n" 30 " .type = BPF_MAP_TYPE_ARRAY,\n" 31 " .key_size = sizeof(int),\n" 32 " .value_size = sizeof(int),\n" 33 " .max_entries = 1,\n" 36 "int this_is_a_global_val;\n" 38 "SEC(\"func=sys_write\")\n" 39 "int bpf_func__sys_write(void *ctx)\n" 45 " * Incorrect relocation. Should not allow this program be\n" 46 " * loaded into kernel.\n" 48 " bpf_map_update_elem(&this_is_a_global_val, &key, &value, 0);\n" 51 "char _license[] SEC(\"license\") = \"GPL\";\n" 52 "int _version SEC(\"version\") = LINUX_VERSION_CODE;\n"
const char test_llvm__bpf_test_relocation[]