]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/ifuncmod5.c
elf: Refuse to dlopen PIE objects [BZ #24323]
[thirdparty/glibc.git] / elf / ifuncmod5.c
CommitLineData
3c30afc8 1/* Test STT_GNU_IFUNC symbols without direct function call. */
31c759bf 2#include "ifunc-sel.h"
3c30afc8 3
e0ed2fb4
L
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");
3c30afc8
L
11
12static int
13one (void)
14{
15 return 1;
16}
17
18static int
19minus_one (void)
20{
21 return -1;
22}
23
24static int
e364e6f1 25zero (void)
3c30afc8
L
26{
27 return 0;
28}
29
30void * foo_ifunc (void) __asm__ ("foo");
31__asm__(".type foo, %gnu_indirect_function");
32
e364e6f1 33void *
de659123 34inhibit_stack_protector
3c30afc8
L
35foo_ifunc (void)
36{
31c759bf 37 return ifunc_sel (one, minus_one, zero);
3c30afc8
L
38}
39
40void * foo_hidden_ifunc (void) __asm__ ("foo_hidden");
41__asm__(".type foo_hidden, %gnu_indirect_function");
42
e364e6f1 43void *
de659123 44inhibit_stack_protector
3c30afc8
L
45foo_hidden_ifunc (void)
46{
31c759bf 47 return ifunc_sel (minus_one, one, zero);
3c30afc8
L
48}
49
50void * foo_protected_ifunc (void) __asm__ ("foo_protected");
51__asm__(".type foo_protected, %gnu_indirect_function");
52
e364e6f1 53void *
de659123 54inhibit_stack_protector
3c30afc8
L
55foo_protected_ifunc (void)
56{
31c759bf 57 return ifunc_sel (one, zero, minus_one);
3c30afc8
L
58}
59
60/* Test hidden indirect function. */
61__asm__(".hidden foo_hidden");
62
63/* Test protected indirect function. */
64__asm__(".protected foo_protected");