5 int main(int argc
, char *argv
[]) {
7 void *f1_handle
= dlopen("func.shared", RTLD_LAZY
| RTLD_GLOBAL
);
8 if (f1_handle
== NULL
) {
9 fprintf(stderr
, "unable to open 'func.shared': %s\n", dlerror());
13 void (*func
)(void) = (void (*)(void))dlsym(f1_handle
, "func");
15 fprintf(stderr
, "unable to lookup symbol 'func': %s\n", dlerror());
20 void *f2_handle
= dlopen("func2.shared", RTLD_LAZY
| RTLD_GLOBAL
);
21 if (f2_handle
== NULL
) {
22 fprintf(stderr
, "unable to open 'func2.shared': %s\n", dlerror());
26 void (*func2
)(void) = (void (*)(void))dlsym(f2_handle
, "func2");
28 fprintf(stderr
, "unable to lookup symbol 'func2': %s\n", dlerror());
34 void *f3_handle
= dlopen("func3.shared", RTLD_LAZY
| RTLD_GLOBAL
);
35 if (f3_handle
== NULL
) {
36 fprintf(stderr
, "unable to open 'func3.shared': %s\n", dlerror());
40 void (*func3
)(void) = (void (*)(void))dlsym(f3_handle
, "func3");
42 fprintf(stderr
, "unable to lookup symbol 'func3': %s\n", dlerror());
49 void (*gcov_flush1
)() = (void (*)())dlsym(f1_handle
, "__gcov_flush");
50 if (gcov_flush1
== NULL
) {
51 fprintf(stderr
, "unable to find __gcov_flush in func.shared': %s\n", dlerror());
56 void (*gcov_flush2
)() = (void (*)())dlsym(f2_handle
, "__gcov_flush");
57 if (gcov_flush2
== NULL
) {
58 fprintf(stderr
, "unable to find __gcov_flush in func2.shared': %s\n", dlerror());
62 if (gcov_flush1
== gcov_flush2
) {
63 fprintf(stderr
, "Same __gcov_flush found in func.shared and func2.shared\n");
68 if (dlclose(f2_handle
) != 0) {
69 fprintf(stderr
, "unable to close 'func2.shared': %s\n", dlerror());