1
2
3
4#include <linux/bpf.h>
5#include <stdint.h>
6#include "bpf_helpers.h"
7
8char _license[] SEC("license") = "GPL";
9
10static volatile struct data {
11 char in[256];
12 char out[256];
13} data;
14
15struct core_reloc_arrays_output {
16 int a2;
17 char b123;
18 int c1c;
19 int d00d;
20};
21
22struct core_reloc_arrays_substruct {
23 int c;
24 int d;
25};
26
27struct core_reloc_arrays {
28 int a[5];
29 char b[2][3][4];
30 struct core_reloc_arrays_substruct c[3];
31 struct core_reloc_arrays_substruct d[1][2];
32};
33
34SEC("raw_tracepoint/sys_enter")
35int test_core_arrays(void *ctx)
36{
37 struct core_reloc_arrays *in = (void *)&data.in;
38 struct core_reloc_arrays_output *out = (void *)&data.out;
39
40
41 if (BPF_CORE_READ(&out->a2, &in->a[2]))
42 return 1;
43
44 if (BPF_CORE_READ(&out->b123, &in->b[1][2][3]))
45 return 1;
46
47 if (BPF_CORE_READ(&out->c1c, &in->c[1].c))
48 return 1;
49
50 if (BPF_CORE_READ(&out->d00d, &in->d[0][0].d))
51 return 1;
52
53 return 0;
54}
55
56