MIPS: Add relocation types
[glibc.git] / elf / ifuncmain1.c
blob6effce3d77b1f7067f07045bf0af898dcdcce508
1 /* Test STT_GNU_IFUNC symbols:
3 1. Direct function call.
4 2. Function pointer.
5 3. Visibility without override.
6 */
8 #include <stdlib.h>
10 int ret_foo;
11 int ret_foo_hidden;
12 int ret_foo_protected;
14 extern int foo (void);
15 extern int foo_protected (void);
17 #ifndef FOO_P
18 typedef int (*foo_p) (void);
19 #endif
21 foo_p foo_ptr = foo;
23 /* Address-significant access to protected symbols is not supported in
24 position-dependent mode on several architectures because GCC
25 generates relocations that assume that the address is local to the
26 main program. */
27 #ifdef __PIE__
28 foo_p foo_procted_ptr = foo_protected;
29 #endif
31 extern foo_p get_foo_p (void);
32 extern foo_p get_foo_hidden_p (void);
33 extern foo_p get_foo_protected_p (void);
35 int
36 main (void)
38 foo_p p;
40 if (foo_ptr != foo)
41 abort ();
42 if (foo () != -1)
43 abort ();
44 if ((*foo_ptr) () != -1)
45 abort ();
47 #ifdef __PIE__
48 if (foo_procted_ptr != foo_protected)
49 abort ();
50 #endif
51 if (foo_protected () != 0)
52 abort ();
53 #ifdef __PIE__
54 if ((*foo_procted_ptr) () != 0)
55 abort ();
56 #endif
58 p = get_foo_p ();
59 if (p != foo)
60 abort ();
61 if (ret_foo != -1 || (*p) () != ret_foo)
62 abort ();
64 p = get_foo_hidden_p ();
65 if (ret_foo_hidden != 1 || (*p) () != ret_foo_hidden)
66 abort ();
68 p = get_foo_protected_p ();
69 #ifdef __PIE__
70 if (p != foo_protected)
71 abort ();
72 #endif
73 if (ret_foo_protected != 0 || (*p) () != ret_foo_protected)
74 abort ();
76 return 0;