Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/jit.dg/verify-dynamic-library.c @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
/* 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; }