lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /* Test 3 STT_GNU_IFUNC symbols. */ |
| 2 | |
| 3 | #include "ifunc-sel.h" |
| 4 | |
| 5 | int 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. */ |
| 11 | asm (".protected global"); |
| 12 | |
| 13 | static int |
| 14 | one (void) |
| 15 | { |
| 16 | return 1; |
| 17 | } |
| 18 | |
| 19 | static int |
| 20 | minus_one (void) |
| 21 | { |
| 22 | return -1; |
| 23 | } |
| 24 | |
| 25 | static int |
| 26 | zero (void) |
| 27 | { |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | void * foo1_ifunc (void) __asm__ ("foo1"); |
| 32 | __asm__(".type foo1, %gnu_indirect_function"); |
| 33 | |
| 34 | void * |
| 35 | foo1_ifunc (void) |
| 36 | { |
| 37 | return ifunc_sel (one, minus_one, zero); |
| 38 | } |
| 39 | |
| 40 | void * foo2_ifunc (void) __asm__ ("foo2"); |
| 41 | __asm__(".type foo2, %gnu_indirect_function"); |
| 42 | |
| 43 | void * |
| 44 | foo2_ifunc (void) |
| 45 | { |
| 46 | return ifunc_sel (minus_one, one, zero); |
| 47 | } |
| 48 | |
| 49 | void * foo3_ifunc (void) __asm__ ("foo3"); |
| 50 | __asm__(".type foo3, %gnu_indirect_function"); |
| 51 | |
| 52 | void * |
| 53 | foo3_ifunc (void) |
| 54 | { |
| 55 | return ifunc_sel (one, zero, minus_one); |
| 56 | } |