lx_kit: update 'arch_execute()' functions based on libc
This ensures proper stack alignment for FPU instructions on x86_64. Fixes #3356
This commit is contained in:
parent
c2c33d6808
commit
c7d9df6350
|
@ -34,6 +34,7 @@ void arch_execute(void *sp, void *func, void *arg)
|
||||||
{
|
{
|
||||||
asm volatile ("mov r0, %2;" /* set arg */
|
asm volatile ("mov r0, %2;" /* set arg */
|
||||||
"mov sp, %0;" /* set stack */
|
"mov sp, %0;" /* set stack */
|
||||||
|
"mov fp, #0;" /* clear frame pointer */
|
||||||
"mov pc, %1;" /* call func */
|
"mov pc, %1;" /* call func */
|
||||||
""
|
""
|
||||||
: : "r"(sp), "r"(func), "r"(arg) : "r0");
|
: : "r"(sp), "r"(func), "r"(arg) : "r0");
|
||||||
|
|
|
@ -35,6 +35,7 @@ void arch_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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,15 @@ extern "C" {
|
||||||
static inline
|
static inline
|
||||||
void arch_execute(void *sp, void *func, void *arg)
|
void arch_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 /* _ARCH_EXECUTE_H_ */
|
#endif /* _ARCH_EXECUTE_H_ */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user