]>
Commit | Line | Data |
---|---|---|
9654e2ae AN |
1 | // SPDX-License-Identifier: GPL-2.0 |
2 | // Copyright (c) 2019 Facebook | |
3 | ||
4 | #include <linux/bpf.h> | |
5 | #include <stdint.h> | |
6 | #include "bpf_helpers.h" | |
7db3822a | 7 | #include "bpf_core_read.h" |
9654e2ae AN |
8 | |
9 | char _license[] SEC("license") = "GPL"; | |
10 | ||
393cdfbe | 11 | struct { |
9654e2ae AN |
12 | char in[256]; |
13 | char out[256]; | |
393cdfbe | 14 | } data = {}; |
9654e2ae AN |
15 | |
16 | struct core_reloc_mods_output { | |
17 | int a, b, c, d, e, f, g, h; | |
18 | }; | |
19 | ||
20 | typedef const int int_t; | |
21 | typedef const char *char_ptr_t; | |
22 | typedef const int arr_t[7]; | |
23 | ||
24 | struct core_reloc_mods_substruct { | |
25 | int x; | |
26 | int y; | |
27 | }; | |
28 | ||
29 | typedef struct { | |
30 | int x; | |
31 | int y; | |
32 | } core_reloc_mods_substruct_t; | |
33 | ||
34 | struct core_reloc_mods { | |
35 | int a; | |
36 | int_t b; | |
37 | char *c; | |
38 | char_ptr_t d; | |
39 | int e[3]; | |
40 | arr_t f; | |
41 | struct core_reloc_mods_substruct g; | |
42 | core_reloc_mods_substruct_t h; | |
43 | }; | |
44 | ||
694731e8 AN |
45 | #define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src) |
46 | ||
9654e2ae AN |
47 | SEC("raw_tracepoint/sys_enter") |
48 | int test_core_mods(void *ctx) | |
49 | { | |
50 | struct core_reloc_mods *in = (void *)&data.in; | |
51 | struct core_reloc_mods_output *out = (void *)&data.out; | |
52 | ||
694731e8 AN |
53 | if (CORE_READ(&out->a, &in->a) || |
54 | CORE_READ(&out->b, &in->b) || | |
55 | CORE_READ(&out->c, &in->c) || | |
56 | CORE_READ(&out->d, &in->d) || | |
57 | CORE_READ(&out->e, &in->e[2]) || | |
58 | CORE_READ(&out->f, &in->f[1]) || | |
59 | CORE_READ(&out->g, &in->g.x) || | |
60 | CORE_READ(&out->h, &in->h.y)) | |
9654e2ae AN |
61 | return 1; |
62 | ||
63 | return 0; | |
64 | } | |
65 |