| 1 |
/* Test for __attribute__((preserve_access_index)) for BPF CO-RE support |
| 2 |
for nested structure. |
| 3 |
|
| 4 |
Note that even though struct O lacks the attribute, when accessed as a |
| 5 |
member of another attributed type, CO-RE relocations should still be |
| 6 |
generated. */ |
| 7 |
|
| 8 |
/* { dg-do compile } */ |
| 9 |
/* { dg-options "-O0 -dA -gbtf -mco-re -masm=normal" } */ |
| 10 |
|
| 11 |
struct O { |
| 12 |
int e; |
| 13 |
int f; |
| 14 |
}; |
| 15 |
|
| 16 |
struct S { |
| 17 |
int a; |
| 18 |
struct { |
| 19 |
int b; |
| 20 |
int c; |
| 21 |
} inner; |
| 22 |
struct O other; |
| 23 |
} __attribute__((preserve_access_index)); |
| 24 |
|
| 25 |
void |
| 26 |
func (struct S *foo) |
| 27 |
{ |
| 28 |
/* 0:1:1 */ |
| 29 |
int *x = &(foo->inner.c); |
| 30 |
|
| 31 |
/* 0:2:0 */ |
| 32 |
int *y = &(foo->other.e); |
| 33 |
|
| 34 |
*x = 4; |
| 35 |
*y = 5; |
| 36 |
} |
| 37 |
|
| 38 |
/* { dg-final { scan-assembler-times "ascii \"0:1:1.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ |
| 39 |
/* { dg-final { scan-assembler-times "ascii \"0:2:0.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ |
| 40 |
|
| 41 |
/* { dg-final { scan-assembler-times "bpfcr_type" 2 } } */ |