Fix pread consolidation on ports that require argument alignment
[glibc.git] / elf / ifuncmain6pie.c
blob8478d4c408d16c1dc107245e1040217d02d85ae2
1 /* Test STT_GNU_IFUNC symbols in PIE:
3 1. Direct function call.
4 2. Function pointer.
5 3. Reference from a shared library.
6 */
8 #include <stdlib.h>
9 #include "ifunc-sel.h"
11 typedef int (*foo_p) (void);
12 extern foo_p foo_ptr;
14 static int
15 one (void)
17 return -30;
20 void * foo_ifunc (void) __asm__ ("foo");
21 __asm__(".type foo, %gnu_indirect_function");
23 void *
24 foo_ifunc (void)
26 return ifunc_one (one);
29 extern int foo (void);
30 extern foo_p get_foo (void);
31 extern foo_p get_foo_p (void);
33 foo_p my_foo_ptr = foo;
35 int
36 main (void)
38 foo_p p;
40 p = get_foo ();
41 if (p != foo)
42 abort ();
43 if ((*p) () != -30)
44 abort ();
46 p = get_foo_p ();
47 if (p != foo)
48 abort ();
49 if ((*p) () != -30)
50 abort ();
52 if (foo_ptr != foo)
53 abort ();
54 if (my_foo_ptr != foo)
55 abort ();
56 if ((*foo_ptr) () != -30)
57 abort ();
58 if ((*my_foo_ptr) () != -30)
59 abort ();
60 if (foo () != -30)
61 abort ();
63 return 0;