gdb: include gdb_wait.h in gdb_wait.c
[deliverable/binutils-gdb.git] / gold / testsuite / ifuncmain7.c
CommitLineData
7223e9ca
ILT
1/* Test local STT_GNU_IFUNC symbols:
2
3 1. Direct function call.
4 2. Function pointer.
5 */
6
7#include <stdlib.h>
8#include "ifunc-sel.h"
9
10extern int foo (void);
11
12static int
13one (void)
14{
15 return -30;
16}
17
6695e4b3 18static void * __attribute__ ((used)) foo_ifunc (void) __asm__ ("foo");
7223e9ca
ILT
19__asm__(".type foo, %gnu_indirect_function");
20
21static void *
22__attribute__ ((used))
23foo_ifunc (void)
24{
25 return ifunc_one (one);
26}
27
28typedef int (*foo_p) (void);
29
30extern foo_p __attribute__ ((noinline)) get_foo_p (void);
31extern foo_p __attribute__ ((noinline)) get_foo (void);
32
33foo_p foo_ptr = foo;
34
35foo_p
36__attribute__ ((noinline))
37get_foo_p (void)
38{
39 return foo_ptr;
40}
41
42foo_p
43__attribute__ ((noinline))
44get_foo (void)
45{
46 return foo;
47}
48
49int
50main (void)
51{
52 foo_p p;
53
54 p = get_foo ();
55 if (p != foo)
56 abort ();
57 if ((*p) () != -30)
58 abort ();
59
60 p = get_foo_p ();
61 if (p != foo)
62 abort ();
63 if ((*p) () != -30)
64 abort ();
65
66 if (foo_ptr != foo)
67 abort ();
68 if ((*foo_ptr) () != -30)
69 abort ();
70 if (foo () != -30)
71 abort ();
72
73 return 0;
74}
This page took 0.552091 seconds and 4 git commands to generate.