$ chmod +x libsomelibrary.so
$ ./libsomelibrary.so
Segmentation fault
$ gcc -O2 http://vi-server.org/vi/bin/rundll.c -ldl -o rundll
$ ./rundll ./libsomelibrary.so main
(application starts normally)
Why can't I just start libsomelibrary.so if it has usable entry point?
rundll.c
is trivial:
void* d = dlopen(argv[1], RTLD_LAZY);
void* m = dlsym(d, argv[2]);
return ((int(*)(int,char**,char**))m)(argc-2, argv+2, envp);
Why is it not used internally when attempting to load a binary?