about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-07-16 21:47:26 +0200
committerptitSeb <sebastien.chev@gmail.com>2022-07-16 21:47:26 +0200
commit4142cc296bc17f0ac7de45f22685e2d2d027a7ef (patch)
tree3506fa8e13a1b7e5eee9dae6f8ff56fca245c825 /src
parente98b1e6716a5f5fb73347f0a0c8551a293aa1956 (diff)
downloadbox64-4142cc296bc17f0ac7de45f22685e2d2d027a7ef.tar.gz
box64-4142cc296bc17f0ac7de45f22685e2d2d027a7ef.zip
tls parameter of clone libc function needs special treatment (not done yet)
Diffstat (limited to 'src')
-rwxr-xr-xsrc/wrapped/wrappedlibc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index 8b3e5428..3c1b7a82 100755
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -1911,7 +1911,7 @@ EXPORT int32_t my___register_atfork(x64emu_t *emu, void* prepare, void* parent,
 EXPORT uint64_t my___umoddi3(uint64_t a, uint64_t b)
 {
     return a%b;
-}
+}  
 EXPORT uint64_t my___udivdi3(uint64_t a, uint64_t b)
 {
     return a/b;
@@ -2692,6 +2692,7 @@ typedef struct clone_arg_s {
  uintptr_t fnc;
  void* args;
  int stack_clone_used;
+ void* tls;
 } clone_arg_t;
 static int clone_fn(void* p)
 {
@@ -2707,22 +2708,26 @@ static int clone_fn(void* p)
 
 EXPORT int my_clone(x64emu_t* emu, void* fn, void* stack, int flags, void* args, void* parent, void* tls, void* child)
 {
+    printf_log(LOG_DEBUG, "my_clone(fn:%p(%s), stack:%p, 0x%x, args:%p, %p, %p, %p)", fn, getAddrFunctionName((uintptr_t)fn), stack, flags, args, parent, tls, child);
     void* mystack = NULL;
     clone_arg_t* arg = (clone_arg_t*)calloc(1, sizeof(clone_arg_t));
     if(my_context->stack_clone_used) {
-        mystack = malloc(1024*1024);  // stack for own process... memory leak, but no practical way to remove it
+        printf_log(LOG_DEBUG, " no free stack_clone ");
+        mystack = malloc(4*1024*1024);  // stack for own process... memory leak, but no practical way to remove it
     } else {
         if(!my_context->stack_clone)
-            my_context->stack_clone = malloc(1024*1024);
+            my_context->stack_clone = malloc(4*1024*1024);
         mystack = my_context->stack_clone;
+        printf_log(LOG_DEBUG, " using stack_clone ");
         my_context->stack_clone_used = 1;
         arg->stack_clone_used = 1;
     }
     arg->stack = (uintptr_t)stack &~7LL;
     arg->args = args;
     arg->fnc = (uintptr_t)fn;
+    arg->tls = tls;
     // x86_64 raw clone is long clone(unsigned long flags, void *stack, int *parent_tid, int *child_tid, unsigned long tls);
-    int64_t ret = clone(clone_fn, (void*)((uintptr_t)mystack+1024*1024), flags, arg, parent, tls, child);
+    int64_t ret = clone(clone_fn, (void*)((uintptr_t)mystack+1024*1024), flags, arg, parent, NULL, child);
     return (uintptr_t)ret;
 }