#endif
 
 /*
- * BPF_CORE_READ abstracts away bpf_probe_read() call and captures offset
+ * bpf_core_read() abstracts away bpf_probe_read() call and captures offset
  * relocation for source address using __builtin_preserve_access_index()
  * built-in, provided by Clang.
  *
  * actual field offset, based on target kernel BTF type that matches original
  * (local) BTF, used to record relocation.
  */
-#define BPF_CORE_READ(dst, src)                                                \
-       bpf_probe_read((dst), sizeof(*(src)),                           \
-                      __builtin_preserve_access_index(src))
+#define bpf_core_read(dst, sz, src)                                        \
+       bpf_probe_read(dst, sz,                                             \
+                      (const void *)__builtin_preserve_access_index(src))
 
 #endif
 
        struct core_reloc_arrays_substruct d[1][2];
 };
 
+#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
+
 SEC("raw_tracepoint/sys_enter")
 int test_core_arrays(void *ctx)
 {
        struct core_reloc_arrays_output *out = (void *)&data.out;
 
        /* in->a[2] */
-       if (BPF_CORE_READ(&out->a2, &in->a[2]))
+       if (CORE_READ(&out->a2, &in->a[2]))
                return 1;
        /* in->b[1][2][3] */
-       if (BPF_CORE_READ(&out->b123, &in->b[1][2][3]))
+       if (CORE_READ(&out->b123, &in->b[1][2][3]))
                return 1;
        /* in->c[1].c */
-       if (BPF_CORE_READ(&out->c1c, &in->c[1].c))
+       if (CORE_READ(&out->c1c, &in->c[1].c))
                return 1;
        /* in->d[0][0].d */
-       if (BPF_CORE_READ(&out->d00d, &in->d[0][0].d))
+       if (CORE_READ(&out->d00d, &in->d[0][0].d))
                return 1;
 
        return 0;
 
        };
 };
 
+#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
+
 SEC("raw_tracepoint/sys_enter")
 int test_core_flavors(void *ctx)
 {
        struct core_reloc_flavors *out = (void *)&data.out;
 
        /* read a using weird layout */
-       if (BPF_CORE_READ(&out->a, &in_weird->a))
+       if (CORE_READ(&out->a, &in_weird->a))
                return 1;
        /* read b using reversed layout */
-       if (BPF_CORE_READ(&out->b, &in_rev->b))
+       if (CORE_READ(&out->b, &in_rev->b))
                return 1;
        /* read c using original layout */
-       if (BPF_CORE_READ(&out->c, &in_orig->c))
+       if (CORE_READ(&out->c, &in_orig->c))
                return 1;
 
        return 0;
 
        int64_t         s64_field;
 };
 
+#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
+
 SEC("raw_tracepoint/sys_enter")
 int test_core_ints(void *ctx)
 {
        struct core_reloc_ints *in = (void *)&data.in;
        struct core_reloc_ints *out = (void *)&data.out;
 
-       if (BPF_CORE_READ(&out->u8_field, &in->u8_field) ||
-           BPF_CORE_READ(&out->s8_field, &in->s8_field) ||
-           BPF_CORE_READ(&out->u16_field, &in->u16_field) ||
-           BPF_CORE_READ(&out->s16_field, &in->s16_field) ||
-           BPF_CORE_READ(&out->u32_field, &in->u32_field) ||
-           BPF_CORE_READ(&out->s32_field, &in->s32_field) ||
-           BPF_CORE_READ(&out->u64_field, &in->u64_field) ||
-           BPF_CORE_READ(&out->s64_field, &in->s64_field))
+       if (CORE_READ(&out->u8_field, &in->u8_field) ||
+           CORE_READ(&out->s8_field, &in->s8_field) ||
+           CORE_READ(&out->u16_field, &in->u16_field) ||
+           CORE_READ(&out->s16_field, &in->s16_field) ||
+           CORE_READ(&out->u32_field, &in->u32_field) ||
+           CORE_READ(&out->s32_field, &in->s32_field) ||
+           CORE_READ(&out->u64_field, &in->u64_field) ||
+           CORE_READ(&out->s64_field, &in->s64_field))
                return 1;
 
        return 0;
 
        int tgid;
 };
 
+#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
+
 SEC("raw_tracepoint/sys_enter")
 int test_core_kernel(void *ctx)
 {
        uint64_t pid_tgid = bpf_get_current_pid_tgid();
        int pid, tgid;
 
-       if (BPF_CORE_READ(&pid, &task->pid) ||
-           BPF_CORE_READ(&tgid, &task->tgid))
+       if (CORE_READ(&pid, &task->pid) ||
+           CORE_READ(&tgid, &task->tgid))
                return 1;
 
        /* validate pid + tgid matches */
 
        int b;
 };
 
+#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
+
 SEC("raw_tracepoint/sys_enter")
 int test_core_misc(void *ctx)
 {
        struct core_reloc_misc_output *out = (void *)&data.out;
 
        /* record two different relocations with the same accessor string */
-       if (BPF_CORE_READ(&out->a, &in_a->a1) ||        /* accessor: 0:0 */
-           BPF_CORE_READ(&out->b, &in_b->b1))          /* accessor: 0:0 */
+       if (CORE_READ(&out->a, &in_a->a1) ||            /* accessor: 0:0 */
+           CORE_READ(&out->b, &in_b->b1))              /* accessor: 0:0 */
                return 1;
 
        /* Validate relocations capture array-only accesses for structs with
         * fixed header, but with potentially extendable tail. This will read
         * first 4 bytes of 2nd element of in_ext array of potentially
         * variably sized struct core_reloc_misc_extensible. */ 
-       if (BPF_CORE_READ(&out->c, &in_ext[2]))         /* accessor: 2 */
+       if (CORE_READ(&out->c, &in_ext[2]))             /* accessor: 2 */
                return 1;
 
        return 0;
 
        core_reloc_mods_substruct_t h;
 };
 
+#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
+
 SEC("raw_tracepoint/sys_enter")
 int test_core_mods(void *ctx)
 {
        struct core_reloc_mods *in = (void *)&data.in;
        struct core_reloc_mods_output *out = (void *)&data.out;
 
-       if (BPF_CORE_READ(&out->a, &in->a) ||
-           BPF_CORE_READ(&out->b, &in->b) ||
-           BPF_CORE_READ(&out->c, &in->c) ||
-           BPF_CORE_READ(&out->d, &in->d) ||
-           BPF_CORE_READ(&out->e, &in->e[2]) ||
-           BPF_CORE_READ(&out->f, &in->f[1]) ||
-           BPF_CORE_READ(&out->g, &in->g.x) ||
-           BPF_CORE_READ(&out->h, &in->h.y))
+       if (CORE_READ(&out->a, &in->a) ||
+           CORE_READ(&out->b, &in->b) ||
+           CORE_READ(&out->c, &in->c) ||
+           CORE_READ(&out->d, &in->d) ||
+           CORE_READ(&out->e, &in->e[2]) ||
+           CORE_READ(&out->f, &in->f[1]) ||
+           CORE_READ(&out->g, &in->g.x) ||
+           CORE_READ(&out->h, &in->h.y))
                return 1;
 
        return 0;
 
        } b;
 };
 
+#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
+
 SEC("raw_tracepoint/sys_enter")
 int test_core_nesting(void *ctx)
 {
        struct core_reloc_nesting *in = (void *)&data.in;
        struct core_reloc_nesting *out = (void *)&data.out;
 
-       if (BPF_CORE_READ(&out->a.a.a, &in->a.a.a))
+       if (CORE_READ(&out->a.a.a, &in->a.a.a))
                return 1;
-       if (BPF_CORE_READ(&out->b.b.b, &in->b.b.b))
+       if (CORE_READ(&out->b.b.b, &in->b.b.b))
                return 1;
 
        return 0;
 
        int (*f)(const char *);
 };
 
+#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
+
 SEC("raw_tracepoint/sys_enter")
 int test_core_primitives(void *ctx)
 {
        struct core_reloc_primitives *in = (void *)&data.in;
        struct core_reloc_primitives *out = (void *)&data.out;
 
-       if (BPF_CORE_READ(&out->a, &in->a) ||
-           BPF_CORE_READ(&out->b, &in->b) ||
-           BPF_CORE_READ(&out->c, &in->c) ||
-           BPF_CORE_READ(&out->d, &in->d) ||
-           BPF_CORE_READ(&out->f, &in->f))
+       if (CORE_READ(&out->a, &in->a) ||
+           CORE_READ(&out->b, &in->b) ||
+           CORE_READ(&out->c, &in->c) ||
+           CORE_READ(&out->d, &in->d) ||
+           CORE_READ(&out->f, &in->f))
                return 1;
 
        return 0;
 
        int a;
 };
 
+#define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src)
+
 SEC("raw_tracepoint/sys_enter")
 int test_core_ptr_as_arr(void *ctx)
 {
        struct core_reloc_ptr_as_arr *in = (void *)&data.in;
        struct core_reloc_ptr_as_arr *out = (void *)&data.out;
 
-       if (BPF_CORE_READ(&out->a, &in[2].a))
+       if (CORE_READ(&out->a, &in[2].a))
                return 1;
 
        return 0;