Merge commit 'origin/master' into fedora/master
[glibc.git] / elf / ifuncmain7.c
blob099e929ffcb6c9be727484ce7b32c97a4e92b754
1 /* Test local STT_GNU_IFUNC symbols:
3 1. Direct function call.
4 2. Function pointer.
5 */
7 #include <stdlib.h>
9 extern int foo (void);
11 static int
12 one (void)
14 return -30;
17 static void * foo_ifunc (void) __asm__ ("foo");
18 __asm__(".type foo, %gnu_indirect_function");
20 static void *
21 __attribute__ ((used))
22 foo_ifunc (void)
24 return one;
27 typedef int (*foo_p) (void);
29 foo_p foo_ptr = foo;
31 foo_p
32 __attribute__ ((noinline))
33 get_foo_p (void)
35 return foo_ptr;
38 foo_p
39 __attribute__ ((noinline))
40 get_foo (void)
42 return foo;
45 int
46 main (void)
48 foo_p p;
50 p = get_foo ();
51 if (p != foo)
52 abort ();
53 if ((*p) () != -30)
54 abort ();
56 p = get_foo_p ();
57 if (p != foo)
58 abort ();
59 if ((*p) () != -30)
60 abort ();
62 if (foo_ptr != foo)
63 abort ();
64 if ((*foo_ptr) () != -30)
65 abort ();
66 if (foo () != -30)
67 abort ();
69 return 0;