dde_bsd: update 'platform_execute()' functions based on libc

This ensures proper stack alignment for FPU instructions on x86_64.

Fixes #3357
This commit is contained in:
Christian Prochaska 2019-04-17 19:33:23 +02:00 committed by Christian Helmuth
parent c7d9df6350
commit 3fa994a7a4
2 changed files with 10 additions and 5 deletions

View File

@ -36,6 +36,7 @@ void platform_execute(void *sp, void *func, void *arg)
asm volatile ("movl %2, 0(%0);" asm volatile ("movl %2, 0(%0);"
"movl %1, -0x4(%0);" "movl %1, -0x4(%0);"
"movl %0, %%esp;" "movl %0, %%esp;"
"xorl %%ebp, %%ebp;" /* clear frame pointer */
"call *-4(%%esp);" "call *-4(%%esp);"
: : "r" (sp), "r" (func), "r" (arg)); : : "r" (sp), "r" (func), "r" (arg));
} }

View File

@ -34,11 +34,15 @@ int _setjmp(jmp_buf);
static inline static inline
void platform_execute(void *sp, void *func, void *arg) void platform_execute(void *sp, void *func, void *arg)
{ {
asm volatile ("movq %2, %%rdi;" asm volatile ("movq %0, %%rsp;" /* load stack pointer */
"movq %1, 0(%0);" "movq %%rsp, %%rbp;" /* caller stack frame (for GDB debugging) */
"movq %0, %%rsp;" "movq %0, -8(%%rbp);"
"call *0(%%rsp);" "movq %1, -16(%%rbp);"
: "+r" (sp), "+r" (func), "+r" (arg) : : "memory"); "movq %2, -24(%%rbp);"
"sub $24, %%rsp;" /* adjust to next stack frame */
"movq %2, %%rdi;" /* 1st argument */
"call *-16(%%rbp);" /* call func */
: : "r" (sp), "r" (func), "r" (arg));
} }
#endif /* _X86_64__PLATFORM_H_ */ #endif /* _X86_64__PLATFORM_H_ */