execute .so
Posted: Wed Mar 06, 2019 2:48 pm
hi again.. been busy with some music stuff, but now i'm back to coding again..
in my toolkit, each plugin format is more or less just a thin wrapper that acts as a 'translator' between the host and our internal plugin format, and the plugin code itself is separated from the wrapper code.. so, i recently added the possibility to have all the plugin format wrappers in the same binary .so file.. and it seems to work pretty well..
since i can also compile a plugin as a standalone executable, i wanted to experiment with the possibility of executing the final shared object (.so) as a normal executable too.. after some googling and testing, i found this: https://stackoverflow.com/questions/301 ... bject-file
main.c:
compile:
then i can just execute the main.so file:
and it prints out the "hello executable.." text string..
but is this 'safe'?
what about that /lib64/ld-linux-x86-64.so.2
is this valid across distributions? versions?
- tor-helge
in my toolkit, each plugin format is more or less just a thin wrapper that acts as a 'translator' between the host and our internal plugin format, and the plugin code itself is separated from the wrapper code.. so, i recently added the possibility to have all the plugin format wrappers in the same binary .so file.. and it seems to work pretty well..
since i can also compile a plugin as a standalone executable, i wanted to experiment with the possibility of executing the final shared object (.so) as a normal executable too.. after some googling and testing, i found this: https://stackoverflow.com/questions/301 ... bject-file
main.c:
Code: Select all
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef INTERPRETER
const char interp[] __attribute__((section(".interp"))) = INTERPRETER;
#endif
void entry_point(void) {
fprintf(stderr, "hello executable shared object world !\n");
_exit(EXIT_SUCCESS);
}
Code: Select all
gcc main.c -Wall -Wextra -fPIC -shared -o main.so -DINTERPRETER=\"/lib64/ld-linux-x86-64.so.2\" -Wl,-e,entry_point
Code: Select all
./main.so
but is this 'safe'?
what about that /lib64/ld-linux-x86-64.so.2
is this valid across distributions? versions?
- tor-helge