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/bpf_helpers.h> 7 #include <bpf/bpf_core_read.h> 8 9 char _license[] SEC("license") = "GPL"; 10 11 struct { 12 char in[256]; 13 char out[256]; 14 } data = {}; 15 16 struct core_reloc_ptr_as_arr { 17 int a; 18 }; 19 20 #define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src) 21 22 SEC("raw_tracepoint/sys_enter") test_core_ptr_as_arr(void * ctx)23int test_core_ptr_as_arr(void *ctx) 24 { 25 struct core_reloc_ptr_as_arr *in = (void *)&data.in; 26 struct core_reloc_ptr_as_arr *out = (void *)&data.out; 27 28 if (CORE_READ(&out->a, &in[2].a)) 29 return 1; 30 31 return 0; 32 } 33 34