diff options
Diffstat (limited to 'src/libtools')
| -rw-r--r-- | src/libtools/signals.c | 6 | ||||
| -rw-r--r-- | src/libtools/threads.c | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/libtools/signals.c b/src/libtools/signals.c index 1c654983..f39e1170 100644 --- a/src/libtools/signals.c +++ b/src/libtools/signals.c @@ -309,8 +309,10 @@ uint64_t RunFunctionHandler(int* exit, int dynarec, x64_ucontext_t* sigcontext, for (int i=0; i<6; ++i) emu->segs_serial[i] = 0; + int align = nargs&1; + if(nargs>6) - R_RSP -= (nargs-6)*sizeof(void*); // need to push in reverse order + R_RSP -= (nargs-6+align)*sizeof(void*); // need to push in reverse order uint64_t *p = (uint64_t*)R_RSP; @@ -342,7 +344,7 @@ uint64_t RunFunctionHandler(int* exit, int dynarec, x64_ucontext_t* sigcontext, EmuCall(emu, fnc); if(nargs>6 && !emu->flags.longjmp) - R_RSP+=((nargs-6)*sizeof(void*)); + R_RSP+=((nargs-6+align)*sizeof(void*)); if(!emu->flags.longjmp && R_CS==0x33) R_CS = old_cs; diff --git a/src/libtools/threads.c b/src/libtools/threads.c index dad14fe1..d6a49a8a 100644 --- a/src/libtools/threads.c +++ b/src/libtools/threads.c @@ -652,7 +652,14 @@ int EXPORT my_pthread_once(x64emu_t* emu, int* once, void* cb) #endif if(old) return 0; + // make some room and align R_RSP before doing the call (maybe it would be simpler to just use Callback functions) + Push64(emu, R_RBP); // push rbp + R_RBP = R_RSP; // mov rbp, rsp + R_RSP -= 0x200; + R_RSP &= ~63LL; DynaCall(emu, (uintptr_t)cb); // using DynaCall, speedup wine 7.21 initialisation + R_RSP = R_RBP; // mov rsp, rbp + R_RBP = Pop64(emu); // pop rbp return 0; } EXPORT int my___pthread_once(x64emu_t* emu, void* once, void* cb) __attribute__((alias("my_pthread_once"))); |