Debian Codegraph @

testdata/ksym.c

raw symbols SCIP
1 #include "common.h"
2
3 char __license[] __section("license") = "Dual MIT/GPL";
4
5 struct {
6 __uint(type, BPF_MAP_TYPE_ARRAY);
7 __uint(max_entries, 2);
8 __type(key, uint32_t);
9 __type(value, uint64_t);
10 } array_map __section(".maps");
11
12 // Non-weak ksyms must be present in the kernel.
13 extern void bpf_init __ksym;
14 // Weak ksyms are potentially zero at runtime.
15 extern void bpf_trace_run1 __ksym __weak;
16
17 __section("socket") int ksym_test() {
18 uint32_t i;
19 uint64_t val;
20
21 i = 0;
22 val = (uint64_t)&bpf_init;
23 bpf_map_update_elem(&array_map, &i, &val, 0);
24
25 i = 1;
26 val = (uint64_t)&bpf_trace_run1;
27 bpf_map_update_elem(&array_map, &i, &val, 0);
28
29 return 0;
30 }
31
32 extern void non_existing_symbol __ksym __weak;
33
34 __section("socket") int ksym_missing_test() {
35 if (&non_existing_symbol == 0) {
36 return 1;
37 }
38 return 0;
39 }