about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-06-14 16:05:45 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-06-14 16:05:45 +0200
commite350224157354adcbacd1ba55722ffae97e0a735 (patch)
tree90b3b4bc3444f50c00493e31d27e916d6d3e6394 /src
parent730e129a800f2406ff7b879931c433438b69c6cd (diff)
downloadbox64-e350224157354adcbacd1ba55722ffae97e0a735.tar.gz
box64-e350224157354adcbacd1ba55722ffae97e0a735.zip
Added wrapped execl function
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/generated/functions_list.txt1
-rw-r--r--src/wrapped/generated/wrappedlibctypes.h1
-rwxr-xr-xsrc/wrapped/wrappedlibc.c23
-rwxr-xr-xsrc/wrapped/wrappedlibc_private.h2
4 files changed, 25 insertions, 2 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index d3b2636e..43538c6e 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -1420,6 +1420,7 @@ wrappedlibc:
   - swapcontext
   - vprintf
 - iFpV:
+  - execl
   - execlp
   - printf
 - iFSp:
diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h
index e011448e..5473f51a 100644
--- a/src/wrapped/generated/wrappedlibctypes.h
+++ b/src/wrapped/generated/wrappedlibctypes.h
@@ -87,6 +87,7 @@ typedef int64_t (*iFpippppp_t)(void*, int64_t, void*, void*, void*, void*, void*
 	GO(sigaltstack, iFpp_t) \
 	GO(swapcontext, iFpp_t) \
 	GO(vprintf, iFpp_t) \
+	GO(execl, iFpV_t) \
 	GO(execlp, iFpV_t) \
 	GO(printf, iFpV_t) \
 	GO(_IO_file_stat, iFSp_t) \
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index d1426c18..0f7e8ec6 100755
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -1575,6 +1575,27 @@ EXPORT int32_t my_execvp(x64emu_t* emu, const char* path, char* const argv[])
     return execvp(path, argv);
 }
 
+EXPORT int32_t my_execl(x64emu_t* emu, const char* path)
+{
+    int self = isProcSelf(path, "exe");
+    int x86 = FileIsX64ELF(path);
+    printf_log(LOG_DEBUG, "execl(\"%s\", ...), IsX86=%d, self=%d\n", path, x86, self);
+    // count argv...
+    int i=0;
+    while(getVargN(emu, i+1)) ++i;
+    char** newargv = (char**)calloc(i+((x86 || self)?2:1), sizeof(char*));
+    int j=0;
+    if ((x86 || self))
+        newargv[j++] = emu->context->box64path;
+    for (int k=0; k<i; ++k)
+        newargv[j++] = getVargN(emu, k+1);
+    if(self) newargv[1] = emu->context->fullpath;
+    printf_log(LOG_DEBUG, " => execl(\"%s\", %p [\"%s\", \"%s\"...:%d])\n", newargv[0], newargv, newargv[1], i?newargv[2]:"", i);
+    int ret = execv(newargv[0], newargv);
+    free(newargv);
+    return ret;
+}
+
 EXPORT int32_t my_execlp(x64emu_t* emu, const char* path)
 {
     // need to use BOX64_PATH / PATH here...
@@ -1584,7 +1605,7 @@ EXPORT int32_t my_execlp(x64emu_t* emu, const char* path)
     // use fullpath...
     int self = isProcSelf(fullpath, "exe");
     int x86 = FileIsX64ELF(fullpath);
-    printf_log(LOG_DEBUG, "execvp(\"%s\", ...), IsX86=%d / fullpath=\"%s\"\n", path, x86, fullpath);
+    printf_log(LOG_DEBUG, "execlp(\"%s\", ...), IsX86=%d / fullpath=\"%s\"\n", path, x86, fullpath);
     free(fullpath);
     // count argv...
     int i=0;
diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h
index 0263d38f..ccd38944 100755
--- a/src/wrapped/wrappedlibc_private.h
+++ b/src/wrapped/wrappedlibc_private.h
@@ -289,7 +289,7 @@ GO(__errno_location, pFv)
 GO(eventfd, iFui)
 GO(eventfd_read, iFip)
 GO(eventfd_write, iFiU)
-//GO(execl, 
+GOM(execl, iFEpV)
 //GO(execle, 
 GOM(execlp, iFEpV)
 GOM(execv, iFEpp)