Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 │ #include <dlfcn.h>
- 2 │ #include <stdlib.h>
- 3 │ #include <stdio.h>
- 4 │
- 5 │ int main(int argc, char* argv[]) {
- 6 │ void* handle = dlopen("/lib/libm.so.6", RTLD_LAZY);
- 7 │ if (!handle) abort();
- 8 │
- 9 │ void* ptr = dlsym(handle, argv[1]);
- 10 │ if (!ptr) abort();
- 11 │ typedef double (*func_t)(double);
- 12 │
- 13 │ double v;
- 14 │ while (scanf("%lf", &v) != EOF) {
- 15 │ printf("%.10g\n", ((func_t) ptr)(v));
- 16 │ }
- 17 │ dlclose(handle);
- 18 │ }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement