casan/main.c
2024-10-15 17:11:28 +02:00

22 lines
386 B
C

#include <dlfcn.h>
#include <stdio.h>
int main() {
void *handle = dlopen("./libhello.so", RTLD_LAZY);
if (!handle) {
fprintf(stderr, "Error: %s\n", dlerror());
return 1;
}
void (*hello)() = dlsym(handle, "leaky_hello");
if (!hello) {
fprintf(stderr, "Error: %s\n", dlerror());
dlclose(handle);
return 1;
}
hello();
dlclose(handle);
return 0;
}