Upload Tizen:Base source
[external/binutils.git] / gold / testsuite / ifuncmain5.c
1 /* Test STT_GNU_IFUNC symbols with dynamic function pointer only.  */
2
3 #include <stdlib.h>
4
5 extern int foo (void);
6 extern int foo_protected (void);
7
8 typedef int (*foo_p) (void);
9
10 extern foo_p __attribute__ ((noinline)) get_foo (void);
11 extern foo_p __attribute__ ((noinline)) get_foo_protected (void);
12
13 foo_p
14 __attribute__ ((noinline))
15 get_foo (void)
16 {
17   return foo;
18 }
19
20 foo_p
21 __attribute__ ((noinline))
22 get_foo_protected (void)
23 {
24   return foo_protected;
25 }
26
27 int
28 main (void)
29 {
30   foo_p p;
31
32   p = get_foo ();
33   if ((*p) () != -1)
34     abort ();
35
36   p = get_foo_protected ();
37   if ((*p) () != 0)
38     abort ();
39
40   return 0;
41 }