More whitespace cleanups.
[jlayton/glibc.git] / elf / ifuncmain7.c
1 /* Test local STT_GNU_IFUNC symbols:
2
3    1. Direct function call.
4    2. Function pointer.
5  */
6
7 #include <stdlib.h>
8
9 extern int foo (void);
10
11 static int
12 one (void)
13 {
14   return -30;
15 }
16
17 static void * foo_ifunc (void) __asm__ ("foo");
18 __asm__(".type foo, %gnu_indirect_function");
19
20 static void *
21 __attribute__ ((used))
22 foo_ifunc (void)
23 {
24   return one;
25 }
26
27 typedef int (*foo_p) (void);
28
29 foo_p foo_ptr = foo;
30
31 foo_p
32 __attribute__ ((noinline))
33 get_foo_p (void)
34 {
35   return foo_ptr;
36 }
37
38 foo_p
39 __attribute__ ((noinline))
40 get_foo (void)
41 {
42   return foo;
43 }
44
45 int
46 main (void)
47 {
48   foo_p p;
49
50   p = get_foo ();
51   if (p != foo)
52     abort ();
53   if ((*p) () != -30)
54     abort ();
55
56   p = get_foo_p ();
57   if (p != foo)
58     abort ();
59   if ((*p) () != -30)
60     abort ();
61
62   if (foo_ptr != foo)
63     abort ();
64   if ((*foo_ptr) () != -30)
65     abort ();
66   if (foo () != -30)
67     abort ();
68
69   return 0;
70 }