]> git.ipfire.org Git - thirdparty/glibc.git/blob - elf/ifuncmain6pie.c
iconv, localedef: avoid floating point rounding differences [BZ #24372]
[thirdparty/glibc.git] / elf / ifuncmain6pie.c
1 /* Test STT_GNU_IFUNC symbols in PIE:
2
3 1. Direct function call.
4 2. Function pointer.
5 3. Reference from a shared library.
6 */
7
8 #include <stdlib.h>
9 #include "ifunc-sel.h"
10
11 typedef int (*foo_p) (void);
12 extern foo_p foo_ptr;
13
14 static int
15 one (void)
16 {
17 return -30;
18 }
19
20 void * foo_ifunc (void) __asm__ ("foo");
21 __asm__(".type foo, %gnu_indirect_function");
22
23 void *
24 inhibit_stack_protector
25 foo_ifunc (void)
26 {
27 return ifunc_one (one);
28 }
29
30 extern int foo (void);
31 extern foo_p get_foo (void);
32 extern foo_p get_foo_p (void);
33
34 foo_p my_foo_ptr = foo;
35
36 int
37 main (void)
38 {
39 foo_p p;
40
41 p = get_foo ();
42 if (p != foo)
43 abort ();
44 if ((*p) () != -30)
45 abort ();
46
47 p = get_foo_p ();
48 if (p != foo)
49 abort ();
50 if ((*p) () != -30)
51 abort ();
52
53 if (foo_ptr != foo)
54 abort ();
55 if (my_foo_ptr != foo)
56 abort ();
57 if ((*foo_ptr) () != -30)
58 abort ();
59 if ((*my_foo_ptr) () != -30)
60 abort ();
61 if (foo () != -30)
62 abort ();
63
64 return 0;
65 }