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 callback0()26void callback0(){__asm("mov r0, r0 \n\t");} callback1()27void callback1(){__asm("mov r0, r0 \n\t");} callback2()28void callback2(){__asm("mov r0, r0 \n\t");} callback3()29void callback3(){__asm("mov r0, r0 \n\t");} callback4()30void callback4(){__asm("mov r0, r0 \n\t");} 31 test(void)32void 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 foo(void)45void foo (void) 46 { 47 __builtin_abort (); 48 } 49 main(void)50int 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 } 58