1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Facebook
6 #include "bpf_helpers.h"
8 char _license[] SEC("license") = "GPL";
10 static volatile struct data {
15 struct core_reloc_misc_output {
19 struct core_reloc_misc___a {
24 struct core_reloc_misc___b {
29 /* fixed two first members, can be extended with new fields */
30 struct core_reloc_misc_extensible {
35 SEC("raw_tracepoint/sys_enter")
36 int test_core_misc(void *ctx)
38 struct core_reloc_misc___a *in_a = (void *)&data.in;
39 struct core_reloc_misc___b *in_b = (void *)&data.in;
40 struct core_reloc_misc_extensible *in_ext = (void *)&data.in;
41 struct core_reloc_misc_output *out = (void *)&data.out;
43 /* record two different relocations with the same accessor string */
44 if (BPF_CORE_READ(&out->a, &in_a->a1) || /* accessor: 0:0 */
45 BPF_CORE_READ(&out->b, &in_b->b1)) /* accessor: 0:0 */
48 /* Validate relocations capture array-only accesses for structs with
49 * fixed header, but with potentially extendable tail. This will read
50 * first 4 bytes of 2nd element of in_ext array of potentially
51 * variably sized struct core_reloc_misc_extensible. */
52 if (BPF_CORE_READ(&out->c, &in_ext[2])) /* accessor: 2 */