arm: Support pac_key_* register operand for MRS/MSR in Armv8.1-M Mainline
[binutils-gdb.git] / gold / testsuite / ifuncmain6pie.c
blob5c3eb60d4e538c9aff90eb64716747799a96de95
1 /* Test STT_GNU_IFUNC symbols in PIE:
3 1. Direct function call.
4 2. Function pointer.
5 3. Reference from a shared library.
6 */
8 #include <stdlib.h>
9 #include "ifunc-sel.h"
11 typedef int (*foo_p) (void);
13 static int
14 one (void)
16 return -30;
19 void * foo_ifunc (void) __asm__ ("foo");
20 __asm__(".type foo, %gnu_indirect_function");
22 void *
23 foo_ifunc (void)
25 return ifunc_one (one);
28 extern int foo (void);
29 extern int call_foo (void);
30 extern foo_p get_foo_p (void);
32 foo_p foo_ptr = foo;
34 int
35 main (void)
37 foo_p p;
39 if (call_foo () != -30)
40 abort ();
42 p = get_foo_p ();
43 if (p != foo)
44 abort ();
45 if ((*p) () != -30)
46 abort ();
48 if (foo_ptr != foo)
49 abort ();
50 if ((*foo_ptr) () != -30)
51 abort ();
52 if (foo () != -30)
53 abort ();
55 return 0;