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