Fix 32392 [2.44 Regression] gprofng fails to build on i686-linux-gnu
[binutils-gdb.git] / gold / testsuite / ifuncmain7.c
blobc2524aa5eb7b2100939012fc26cc6c36dbc43af1
1 /* Test local STT_GNU_IFUNC symbols:
3 1. Direct function call.
4 2. Function pointer.
5 */
7 #include <stdlib.h>
8 #include "ifunc-sel.h"
10 extern int foo (void);
12 static int
13 one (void)
15 return -30;
18 static void * __attribute__ ((used)) foo_ifunc (void) __asm__ ("foo");
19 __asm__(".type foo, %gnu_indirect_function");
21 static void *
22 __attribute__ ((used))
23 foo_ifunc (void)
25 return ifunc_one (one);
28 typedef int (*foo_p) (void);
30 extern foo_p __attribute__ ((noinline)) get_foo_p (void);
31 extern foo_p __attribute__ ((noinline)) get_foo (void);
33 foo_p foo_ptr = foo;
35 foo_p
36 __attribute__ ((noinline))
37 get_foo_p (void)
39 return foo_ptr;
42 foo_p
43 __attribute__ ((noinline))
44 get_foo (void)
46 return foo;
49 int
50 main (void)
52 foo_p p;
54 p = get_foo ();
55 if (p != foo)
56 abort ();
57 if ((*p) () != -30)
58 abort ();
60 p = get_foo_p ();
61 if (p != foo)
62 abort ();
63 if ((*p) () != -30)
64 abort ();
66 if (foo_ptr != foo)
67 abort ();
68 if ((*foo_ptr) () != -30)
69 abort ();
70 if (foo () != -30)
71 abort ();
73 return 0;