Tweak realloc/MREMAP comment to be more accurate.
[glibc.git] / elf / ifuncmain6pie.c
blob04faeb86ef999019f42fa1843d52edaecd9ca00d
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 inhibit_stack_protector
25 foo_ifunc (void)
27 return ifunc_one (one);
30 extern int foo (void);
31 extern foo_p get_foo (void);
32 extern foo_p get_foo_p (void);
34 foo_p my_foo_ptr = foo;
36 int
37 main (void)
39 foo_p p;
41 p = get_foo ();
42 if (p != foo)
43 abort ();
44 if ((*p) () != -30)
45 abort ();
47 p = get_foo_p ();
48 if (p != foo)
49 abort ();
50 if ((*p) () != -30)
51 abort ();
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 ();
64 return 0;