]>
Commit | Line | Data |
---|---|---|
2f083d75 L |
1 | /* Test STT_GNU_IFUNC symbols: |
2 | ||
3 | 1. Direct function call. | |
4 | 2. Function pointer. | |
5 | 3. Visibility without override. | |
6 | */ | |
7 | ||
8 | #include <stdlib.h> | |
9 | ||
2f083d75 L |
10 | int ret_foo; |
11 | int ret_foo_hidden; | |
12 | int ret_foo_protected; | |
13 | ||
14 | extern int foo (void); | |
15 | extern int foo_protected (void); | |
16 | ||
17 | #ifndef FOO_P | |
18 | typedef int (*foo_p) (void); | |
19 | #endif | |
20 | ||
21 | foo_p foo_ptr = foo; | |
9cc9d61e FW |
22 | |
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__ | |
2f083d75 | 28 | foo_p foo_procted_ptr = foo_protected; |
9cc9d61e | 29 | #endif |
2f083d75 L |
30 | |
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); | |
34 | ||
35 | int | |
36 | main (void) | |
37 | { | |
38 | foo_p p; | |
9c84384c | 39 | |
2f083d75 L |
40 | if (foo_ptr != foo) |
41 | abort (); | |
42 | if (foo () != -1) | |
43 | abort (); | |
44 | if ((*foo_ptr) () != -1) | |
45 | abort (); | |
46 | ||
9cc9d61e | 47 | #ifdef __PIE__ |
2f083d75 L |
48 | if (foo_procted_ptr != foo_protected) |
49 | abort (); | |
9cc9d61e | 50 | #endif |
2f083d75 L |
51 | if (foo_protected () != 0) |
52 | abort (); | |
9cc9d61e | 53 | #ifdef __PIE__ |
2f083d75 L |
54 | if ((*foo_procted_ptr) () != 0) |
55 | abort (); | |
9cc9d61e | 56 | #endif |
2f083d75 L |
57 | |
58 | p = get_foo_p (); | |
59 | if (p != foo) | |
60 | abort (); | |
61 | if (ret_foo != -1 || (*p) () != ret_foo) | |
62 | abort (); | |
63 | ||
64 | p = get_foo_hidden_p (); | |
65 | if (ret_foo_hidden != 1 || (*p) () != ret_foo_hidden) | |
66 | abort (); | |
67 | ||
68 | p = get_foo_protected_p (); | |
9cc9d61e | 69 | #ifdef __PIE__ |
2f083d75 L |
70 | if (p != foo_protected) |
71 | abort (); | |
9cc9d61e | 72 | #endif |
2f083d75 L |
73 | if (ret_foo_protected != 0 || (*p) () != ret_foo_protected) |
74 | abort (); | |
75 | ||
76 | return 0; | |
77 | } |