From 1e5079d215643295cba69ce9d0999bf3c5f5df38 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Tue, 6 Mar 2018 12:11:37 +0300 Subject: triton: prevent alloc_context function to be inlined (fixes improper stack size calculation) --- accel-pppd/triton/triton.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'accel-pppd') diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c index 999a38b2..00a93f30 100644 --- a/accel-pppd/triton/triton.c +++ b/accel-pppd/triton/triton.c @@ -105,6 +105,7 @@ static void* triton_thread(struct _triton_thread_t *thread) { sigset_t set; int sig, need_free; + void *stack; sigfillset(&set); sigdelset(&set, SIGKILL); @@ -133,8 +134,8 @@ static void* triton_thread(struct _triton_thread_t *thread) if (this_ctx->before_switch) this_ctx->before_switch(this_ctx, thread->ctx->bf_arg); - *(void *volatile *)alloca(thread->ctx->uc->uc_stack.ss_size + 64); - barrier(); + stack = alloca(thread->ctx->uc->uc_stack.ss_size + 64); + asm volatile("" :: "m" (stack)); memcpy(thread_frame - thread->ctx->uc->uc_stack.ss_size, thread->ctx->uc->uc_stack.ss_sp, thread->ctx->uc->uc_stack.ss_size); setcontext(thread->ctx->uc); @@ -473,7 +474,7 @@ void triton_context_print(void) printf("%p\n", ctx); } -static ucontext_t *alloc_context() +static ucontext_t * __attribute__((noinline)) alloc_context() { ucontext_t *uc; void *frame = __builtin_frame_address(0); -- cgit v1.2.3