]>
Commit | Line | Data |
---|---|---|
3c30afc8 L |
1 | /* Test STT_GNU_IFUNC symbols without direct function call. */ |
2 | ||
3 | extern int global; | |
4 | ||
5 | static int | |
6 | one (void) | |
7 | { | |
8 | return 1; | |
9 | } | |
10 | ||
11 | static int | |
12 | minus_one (void) | |
13 | { | |
14 | return -1; | |
15 | } | |
16 | ||
17 | static int | |
e364e6f1 | 18 | zero (void) |
3c30afc8 L |
19 | { |
20 | return 0; | |
21 | } | |
22 | ||
23 | void * foo_ifunc (void) __asm__ ("foo"); | |
24 | __asm__(".type foo, %gnu_indirect_function"); | |
25 | ||
e364e6f1 | 26 | void * |
3c30afc8 L |
27 | foo_ifunc (void) |
28 | { | |
29 | switch (global) | |
30 | { | |
31 | case 1: | |
32 | return one; | |
33 | case -1: | |
34 | return minus_one; | |
35 | default: | |
36 | return zero; | |
37 | } | |
38 | } | |
39 | ||
40 | void * foo_hidden_ifunc (void) __asm__ ("foo_hidden"); | |
41 | __asm__(".type foo_hidden, %gnu_indirect_function"); | |
42 | ||
e364e6f1 | 43 | void * |
3c30afc8 L |
44 | foo_hidden_ifunc (void) |
45 | { | |
46 | switch (global) | |
47 | { | |
48 | case 1: | |
49 | return minus_one; | |
50 | case -1: | |
51 | return one; | |
52 | default: | |
53 | return zero; | |
54 | } | |
55 | } | |
56 | ||
57 | void * foo_protected_ifunc (void) __asm__ ("foo_protected"); | |
58 | __asm__(".type foo_protected, %gnu_indirect_function"); | |
59 | ||
e364e6f1 | 60 | void * |
3c30afc8 L |
61 | foo_protected_ifunc (void) |
62 | { | |
63 | switch (global) | |
64 | { | |
65 | case 1: | |
66 | return one; | |
67 | case -1: | |
68 | return zero; | |
69 | default: | |
70 | return minus_one; | |
71 | } | |
72 | } | |
73 | ||
74 | /* Test hidden indirect function. */ | |
75 | __asm__(".hidden foo_hidden"); | |
76 | ||
77 | /* Test protected indirect function. */ | |
78 | __asm__(".protected foo_protected"); |