1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Facebook
6 #include <bpf/bpf_helpers.h>
7 #include <bpf/bpf_core_read.h>
9 char _license[] SEC("license") = "GPL";
16 struct core_reloc_existence_output {
29 struct core_reloc_existence {
41 SEC("raw_tracepoint/sys_enter")
42 int test_core_existence(void *ctx)
44 struct core_reloc_existence *in = (void *)&data.in;
45 struct core_reloc_existence_output *out = (void *)&data.out;
47 out->a_exists = bpf_core_field_exists(in->a);
48 if (bpf_core_field_exists(in->a))
49 out->a_value = BPF_CORE_READ(in, a);
51 out->a_value = 0xff000001u;
53 out->b_exists = bpf_core_field_exists(in->b);
54 if (bpf_core_field_exists(in->b))
55 out->b_value = BPF_CORE_READ(in, b);
57 out->b_value = 0xff000002u;
59 out->c_exists = bpf_core_field_exists(in->c);
60 if (bpf_core_field_exists(in->c))
61 out->c_value = BPF_CORE_READ(in, c);
63 out->c_value = 0xff000003u;
65 out->arr_exists = bpf_core_field_exists(in->arr);
66 if (bpf_core_field_exists(in->arr))
67 out->arr_value = BPF_CORE_READ(in, arr[0]);
69 out->arr_value = 0xff000004u;
71 out->s_exists = bpf_core_field_exists(in->s);
72 if (bpf_core_field_exists(in->s))
73 out->s_value = BPF_CORE_READ(in, s.x);
75 out->s_value = 0xff000005u;