1 /* Test STT_GNU_IFUNC symbols with dlopen:
3 1. Direct function call.
5 3. Visibility with override.
12 extern int __attribute__ ((noinline)) foo (void);
13 extern int __attribute__ ((noinline)) foo_hidden (void);
14 extern int __attribute__ ((noinline)) foo_protected (void);
16 typedef int (*foo_p) (void);
19 __attribute__ ((noinline))
26 __attribute__ ((noinline))
33 __attribute__ ((noinline))
46 void *h = dlopen ("ifuncmod3.so", RTLD_LAZY);
49 printf ("cannot load: %s\n", dlerror ());
56 printf ("symbol not found: %s\n", dlerror ());
62 f = dlsym (h, "get_foo_p");
65 printf ("symbol not found: %s\n", dlerror ());
69 ret = dlsym (h, "ret_foo");
72 printf ("symbol not found: %s\n", dlerror ());
81 if (*ret != -30 || (*p) () != *ret)
84 f = dlsym (h, "get_foo_hidden_p");
87 printf ("symbol not found: %s\n", dlerror ());
91 ret = dlsym (h, "ret_foo_hidden");
94 printf ("symbol not found: %s\n", dlerror ());
99 if (foo_hidden () != -20)
101 if (*ret != 1 || (*p) () != *ret)
104 f = dlsym (h, "get_foo_protected_p");
107 printf ("symbol not found: %s\n", dlerror ());
111 ret = dlsym (h, "ret_foo_protected");
114 printf ("symbol not found: %s\n", dlerror ());
119 if (p == foo_protected)
121 if (foo_protected () != -40)
123 if (*ret != 0 || (*p) () != *ret)
126 if (dlclose (h) != 0)
128 printf ("cannot close: %s\n", dlerror ());