diff options
Diffstat (limited to 'tests/core/c_linkmodes/crypto_test_dl.c')
-rw-r--r-- | tests/core/c_linkmodes/crypto_test_dl.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/core/c_linkmodes/crypto_test_dl.c b/tests/core/c_linkmodes/crypto_test_dl.c new file mode 100644 index 00000000..36e21495 --- /dev/null +++ b/tests/core/c_linkmodes/crypto_test_dl.c @@ -0,0 +1,30 @@ +#include <dlfcn.h> +#include <stdio.h> + +#ifndef SO +#error No SO path defined +#endif + +int main() { + void* handle = dlopen(SO, RTLD_NOW); + if (!handle) { + printf("dlopen: %s\n", dlerror()); + return 1; + } + + typedef void (*gofn_t)(); + gofn_t gofn = (gofn_t)dlsym(handle, "GoFn"); + const char* dlsym_error = dlerror(); + if (dlsym_error) { + printf("dlsym: %s\n", dlerror()); + dlclose(handle); + return 1; + } + + gofn(); + + if (dlclose(handle)) { + printf("dlclose: %s\n", dlerror()); + } + return 0; +} |