blob: 99f9128bc660218f17dc1eb3fdc2a830f487c2f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/* For use by jit-verify-dynamic-library, used by
test-compile-to-dynamic-library.c. */
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
int
main (int argc, char **argv)
{
void *handle;
void (*hello_world) (const char *name);
char *error;
handle = dlopen ("./output-of-test-compile-to-dynamic-library.c.so",
RTLD_NOW | RTLD_LOCAL);
if (!handle)
{
fprintf (stderr, "dlopen failed: %s\n", dlerror());
exit (1);
}
/* Clear any existing error */
dlerror ();
/* This symbol is from the DSO built by
test-compile-to-dynamic-library.c. */
*(void **) (&hello_world) = dlsym (handle, "hello_world");
if ((error = dlerror()) != NULL)
{
fprintf (stderr, "dlsym failed: %s\n", error);
exit (2);
}
/* Call the function from the generated DSO. */
hello_world (argv[0]);
dlclose (handle);
return 0;
}
|