| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-ifunc "" } */ |
| 3 |
/* { dg-require-effective-target pie } */ |
| 4 |
/* { dg-options "-fpie -pie" } */ |
| 5 |
|
| 6 |
#include <stdio.h> |
| 7 |
|
| 8 |
static int __attribute__((noinline)) |
| 9 |
implementation (void) |
| 10 |
{ |
| 11 |
printf ("'ere I am JH\n"); |
| 12 |
return 0; |
| 13 |
} |
| 14 |
|
| 15 |
static __typeof__ (implementation) *resolver (void) |
| 16 |
{ |
| 17 |
return (void *)implementation; |
| 18 |
} |
| 19 |
|
| 20 |
extern int magic (void) __attribute__ ((ifunc ("resolver"))); |
| 21 |
|
| 22 |
__attribute__ ((weak)) |
| 23 |
int |
| 24 |
call_magic (int (*ptr) (void)) |
| 25 |
{ |
| 26 |
return ptr (); |
| 27 |
} |
| 28 |
|
| 29 |
int main () |
| 30 |
{ |
| 31 |
return call_magic (magic); |
| 32 |
} |