blob: 0e65a63691f2e65e7fd0b1897e14c72c1b89605d [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* Test STT_GNU_IFUNC symbols without direct function call. */
2#include "ifunc-sel.h"
3
4int global = -1;
5/* Can't use __attribute__((visibility("protected"))) until the GCC bug:
6
7 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248
8
9 is fixed. */
10asm (".protected global");
11
12static int
13one (void)
14{
15 return 1;
16}
17
18static int
19minus_one (void)
20{
21 return -1;
22}
23
24static int
25zero (void)
26{
27 return 0;
28}
29
30void * foo_ifunc (void) __asm__ ("foo");
31__asm__(".type foo, %gnu_indirect_function");
32
33void *
34foo_ifunc (void)
35{
36 return ifunc_sel (one, minus_one, zero);
37}
38
39void * foo_hidden_ifunc (void) __asm__ ("foo_hidden");
40__asm__(".type foo_hidden, %gnu_indirect_function");
41
42void *
43foo_hidden_ifunc (void)
44{
45 return ifunc_sel (minus_one, one, zero);
46}
47
48void * foo_protected_ifunc (void) __asm__ ("foo_protected");
49__asm__(".type foo_protected, %gnu_indirect_function");
50
51void *
52foo_protected_ifunc (void)
53{
54 return ifunc_sel (one, zero, minus_one);
55}
56
57/* Test hidden indirect function. */
58__asm__(".hidden foo_hidden");
59
60/* Test protected indirect function. */
61__asm__(".protected foo_protected");