allwinner_a64/android/external/valgrind/drd/tests/dlopen_main.c
2018-08-08 16:14:42 +08:00

29 lines
499 B
C

#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
#include "dlopen_lib.h"
int main(int argc, char **argv)
{
const char *lib = argc > 1 ? argv[1] : "./libfoo.so";
void *handle;
void (*function)();
const char *error;
handle = dlopen(lib, RTLD_NOW);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}
function = dlsym(handle, "foo");
error = dlerror();
if (error) {
fputs(error, stderr);
exit(1);
}
(*function)();
dlclose(handle);
return 0;
}