summaryrefslogtreecommitdiff
path: root/quickexec/johns/so_stub.c
Side-by-side diff
Diffstat (limited to 'quickexec/johns/so_stub.c') (more/less context) (ignore whitespace changes)
-rw-r--r--quickexec/johns/so_stub.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/quickexec/johns/so_stub.c b/quickexec/johns/so_stub.c
new file mode 100644
index 0000000..fe71f9c
--- a/dev/null
+++ b/quickexec/johns/so_stub.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+
+
+int main( int argc, char *argv[] ) {
+ char module[1024];
+ int (*loadedMain)( int argc, char *argv[] );
+ char *error;
+ int retVal = 0;
+ void *handle;
+ strcpy( module, argv[0] );
+ strcat( module, ".so" );
+ if ( !(handle = dlopen( module, RTLD_LAZY ) ) )
+ fputs( dlerror(), stderr ), exit( 1 );
+ loadedMain = dlsym( handle, "main" );
+ if ( ( error = dlerror() ) != NULL )
+ fputs( error, stderr ), exit( 1 );
+ retVal = (*loadedMain)( argc, argv );
+ dlclose( handle );
+ return retVal;
+}
+