Automatic date update in version.in
[binutils-gdb.git] / gold / testsuite / ifuncmain1vis.c
blobc16af63ac5ac7ac326dd7fae2b09b5d9311002e4
1 /* Test STT_GNU_IFUNC symbols:
3 1. Direct function call.
4 2. Function pointer.
5 3. Visibility with override.
6 */
8 #include <stdlib.h>
10 int __attribute__ ((noinline)) foo_hidden (void);
12 int ret_foo;
13 int ret_foo_hidden;
14 int ret_foo_protected;
16 extern int foo (void);
17 extern int foo_protected (void);
19 #ifndef FOO_P
20 typedef int (*foo_p) (void);
21 #endif
23 foo_p foo_ptr = foo;
24 foo_p foo_procted_ptr = foo_protected;
26 extern foo_p get_foo_p (void);
27 extern foo_p get_foo_hidden_p (void);
28 extern foo_p get_foo_protected_p (void);
30 int
31 __attribute__ ((noinline))
32 foo (void)
34 return -30;
37 int
38 __attribute__ ((noinline))
39 foo_hidden (void)
41 return -20;
44 int
45 __attribute__ ((noinline))
46 foo_protected (void)
48 return -40;
51 int
52 main (void)
54 foo_p p;
56 if (foo_ptr != foo)
57 abort ();
58 if ((*foo_ptr) () != -30)
59 abort ();
61 if (foo_procted_ptr != foo_protected)
62 abort ();
63 if ((*foo_procted_ptr) () != -40)
64 abort ();
66 p = get_foo_p ();
67 if (p != foo)
68 abort ();
69 if (foo () != -30)
70 abort ();
71 if (ret_foo != -30 || (*p) () != ret_foo)
72 abort ();
74 p = get_foo_hidden_p ();
75 if (foo_hidden () != -20)
76 abort ();
77 if (ret_foo_hidden != 1 || (*p) () != ret_foo_hidden)
78 abort ();
80 p = get_foo_protected_p ();
81 if (p == foo_protected)
82 abort ();
83 if (foo_protected () != -40)
84 abort ();
85 if (ret_foo_protected != 0 || (*p) () != ret_foo_protected)
86 abort ();
88 return 0;