Home | History | Annotate | Download | only in testsuite
      1 /* Test STT_GNU_IFUNC symbols without direct function call.  */
      2 #include "ifunc-sel.h"
      3 
      4 int global __attribute__ ((visibility ("hidden"))) = -1;
      5 
      6 static int
      7 one (void)
      8 {
      9   return 1;
     10 }
     11 
     12 static int
     13 minus_one (void)
     14 {
     15   return -1;
     16 }
     17 
     18 static int
     19 zero (void)
     20 {
     21   return 0;
     22 }
     23 
     24 void * foo_ifunc (void) __asm__ ("foo");
     25 __asm__(".type foo, %gnu_indirect_function");
     26 
     27 void *
     28 foo_ifunc (void)
     29 {
     30   return ifunc_sel (one, minus_one, zero);
     31 }
     32 
     33 void * foo_hidden_ifunc (void) __asm__ ("foo_hidden");
     34 __asm__(".type foo_hidden, %gnu_indirect_function");
     35 
     36 void *
     37 foo_hidden_ifunc (void)
     38 {
     39   return ifunc_sel (minus_one, one, zero);
     40 }
     41 
     42 void * foo_protected_ifunc (void) __asm__ ("foo_protected");
     43 __asm__(".type foo_protected, %gnu_indirect_function");
     44 
     45 void *
     46 foo_protected_ifunc (void)
     47 {
     48   return ifunc_sel (one, zero, minus_one);
     49 }
     50 
     51 /* Test hidden indirect function.  */
     52 __asm__(".hidden foo_hidden");
     53 
     54 /* Test protected indirect function.  */
     55 __asm__(".protected foo_protected");
     56