| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2" } */ |
| 3 |
|
| 4 |
#include <string.h> |
| 5 |
|
| 6 |
struct table_s |
| 7 |
{ |
| 8 |
void (*fun0) |
| 9 |
( void ); |
| 10 |
void (*fun1) |
| 11 |
( void ); |
| 12 |
void (*fun2) |
| 13 |
( void ); |
| 14 |
void (*fun3) |
| 15 |
( void ); |
| 16 |
void (*fun4) |
| 17 |
( void ); |
| 18 |
void (*fun5) |
| 19 |
( void ); |
| 20 |
void (*fun6) |
| 21 |
( void ); |
| 22 |
void (*fun7) |
| 23 |
( void ); |
| 24 |
} table; |
| 25 |
|
| 26 |
void callback0(){__asm("mov r0, r0 \n\t");} |
| 27 |
void callback1(){__asm("mov r0, r0 \n\t");} |
| 28 |
void callback2(){__asm("mov r0, r0 \n\t");} |
| 29 |
void callback3(){__asm("mov r0, r0 \n\t");} |
| 30 |
void callback4(){__asm("mov r0, r0 \n\t");} |
| 31 |
|
| 32 |
void test (void) { |
| 33 |
memset(&table, 0, sizeof table); |
| 34 |
|
| 35 |
asm volatile ("" : : : "r3"); |
| 36 |
|
| 37 |
table.fun0 = callback0; |
| 38 |
table.fun1 = callback1; |
| 39 |
table.fun2 = callback2; |
| 40 |
table.fun3 = callback3; |
| 41 |
table.fun4 = callback4; |
| 42 |
table.fun0(); |
| 43 |
} |
| 44 |
|
| 45 |
void foo (void) |
| 46 |
{ |
| 47 |
__builtin_abort (); |
| 48 |
} |
| 49 |
|
| 50 |
int main (void) |
| 51 |
{ |
| 52 |
unsigned long p = (unsigned long) &foo; |
| 53 |
asm volatile ("mov r3, %0" : : "r" (p)); |
| 54 |
test (); |
| 55 |
|
| 56 |
return 0; |
| 57 |
} |