Created
May 6, 2019 16:06
-
-
Save farseerfc/e607fac3e05f9a570f764eb489d51bd1 to your computer and use it in GitHub Desktop.
trydlopen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void a_f(){ | |
printf("a_f\n"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void a_f(); | |
void b_f(){ | |
a_f(); | |
printf("b_f\n"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dlfcn.h> | |
int main(int argc, char* argv[]){ | |
void (*b_p) (); | |
void * b_so = 0; | |
b_so = dlopen("libb.so.1", RTLD_LAZY); | |
b_p = dlsym(b_so, "b_f"); | |
b_p(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: main libb.so.1.0 liba.so.1.0 | |
libb.so.1.0: b.c | |
gcc --shared -Wl,-soname,libb.so.1 -o libb.so.1.0 b.c | |
ln -sr libb.so.1.0 libb.so.1 | |
liba.so.1.0: a.c | |
gcc --shared -Wl,-soname,liba.so.1 -o liba.so.1.0 a.c | |
ln -sr liba.so.1.0 liba.so.1 | |
main: main.c liba.so.1.0 | |
gcc -Wl,-rpath=. -ldl -o main main.c liba.so.1.0 | |
clean: | |
rm main *.so.* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment