Debian Codegraph @

testdata/subprog_reloc.c

raw symbols SCIP
1 /* This file excercises the ELF loader.
2 */
3
4 #include "common.h"
5
6 char __license[] __section("license") = "MIT";
7
8 struct bpf_map_def hash_map __section("maps") = {
9 .type = BPF_MAP_TYPE_HASH,
10 .key_size = sizeof(uint32_t),
11 .value_size = sizeof(uint64_t),
12 .max_entries = 1,
13 };
14
15 static int sub_prog() {
16 uint32_t key = 0;
17 uint64_t val = 42;
18
19 bpf_map_update_elem(&hash_map, &key, &val, /* BPF_ANY */ 0);
20
21 return 0;
22 }
23
24 __section("xdp") int fp_relocation() {
25 uint32_t key = 0;
26 uint64_t val = 1;
27
28 bpf_map_update_elem(&hash_map, &key, &val, /* BPF_ANY */ 0);
29
30 bpf_for_each_map_elem(&hash_map, sub_prog, (void *)0, 0);
31
32 uint64_t *new_val = bpf_map_lookup_elem(&hash_map, &key);
33 if (!new_val) {
34 return -1;
35 }
36
37 return *new_val;
38 }