]> git.ipfire.org Git - thirdparty/glibc.git/blob - elf/ifuncmain5.c
install.texi: Build was tested with binutils 2.41 (just released)
[thirdparty/glibc.git] / elf / ifuncmain5.c
1 /* Test STT_GNU_IFUNC symbols with dynamic function pointer only. */
2
3 #include <stdlib.h>
4
5 extern int foo (void);
6 extern int foo_protected (void);
7
8 typedef int (*foo_p) (void);
9
10 foo_p
11 __attribute__ ((noinline))
12 get_foo (void)
13 {
14 return foo;
15 }
16
17
18 /* Address-significant access to protected symbols is not supported in
19 position-dependent mode on several architectures because GCC
20 generates relocations that assume that the address is local to the
21 main program. */
22 #ifdef __PIE__
23 foo_p
24 __attribute__ ((noinline))
25 get_foo_protected (void)
26 {
27 return foo_protected;
28 }
29 #endif
30
31 int
32 main (void)
33 {
34 foo_p p;
35
36 p = get_foo ();
37 if ((*p) () != -1)
38 abort ();
39
40 #ifdef __PIE__
41 p = get_foo_protected ();
42 if ((*p) () != 0)
43 abort ();
44 #endif
45
46 return 0;
47 }