| 1 |
/* Basic test for struct __attribute__((preserve_access_index)) |
| 2 |
for BPF CO-RE support. */ |
| 3 |
|
| 4 |
/* { dg-do compile } */ |
| 5 |
/* { dg-options "-O0 -dA -gbtf -mco-re -masm=normal" } */ |
| 6 |
|
| 7 |
struct S { |
| 8 |
int a; |
| 9 |
int b; |
| 10 |
int c; |
| 11 |
} __attribute__((preserve_access_index)); |
| 12 |
|
| 13 |
void |
| 14 |
func (struct S * s) |
| 15 |
{ |
| 16 |
/* This test is marked as XFAIL since for the time being the CO-RE |
| 17 |
implementation is not able to disambiguate between a point manipulation |
| 18 |
and a CO-RE access when using preserve_access_index attribute. The |
| 19 |
current implemetantion is incorrect if we consider that STRUCT S might |
| 20 |
have different size within the kernel. |
| 21 |
This example demonstrates how the implementation of preserve_access_index |
| 22 |
as an attribute of the type is flagile. */ |
| 23 |
|
| 24 |
/* 2:2 */ |
| 25 |
int *x = &((s+2)->c); |
| 26 |
*x = 4; |
| 27 |
|
| 28 |
/* 2:1 */ |
| 29 |
int *y = __builtin_preserve_access_index (&((s+2)->b)); |
| 30 |
*y = 2; |
| 31 |
} |
| 32 |
|
| 33 |
/* { dg-final { scan-assembler-times "ascii \"2:2.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 { xfail *-*-* } } } */ |
| 34 |
/* { dg-final { scan-assembler-times "ascii \"2:1.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ |
| 35 |
/* { dg-final { scan-assembler-times "bpfcr_type" 2 } } */ |