Skip to content

Instantly share code, notes, and snippets.

@ranch-verdin

ranch-verdin/build.sh Secret

Created Feb 8, 2019
Embed
What would you like to do?
gcc dlopen_test.c -ldl
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
int main (void) {
while(1) {
system("gcc -c -fPIC numberwang.c -o numberwang.o");
system("gcc numberwang.o -shared -o numberwang.so");
int (*numberwang)(void);
void *handle = dlopen("./numberwang.so", RTLD_NOW);
numberwang = dlsym(handle, "numberwang");
printf("numberwang: %d!\n", (*numberwang)());
dlclose(handle);
getchar();
}
}
int numberwang (void) {
return 6;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment