diff --git a/src/rt/arch/i386/ccall.S b/src/rt/arch/i386/ccall.S index 3d7063d201a..76edf84e8d0 100644 --- a/src/rt/arch/i386/ccall.S +++ b/src/rt/arch/i386/ccall.S @@ -7,12 +7,33 @@ _asm_call_on_stack: .globl asm_call_on_stack asm_call_on_stack: #endif - pushl %ebp - movl %esp,%ebp // save esp - movl 16(%ebp),%esp // load new esp - subl $12,%esp // maintain 16-byte alignment - pushl 8(%ebp) // push ptr to argument block - calll *12(%ebp) - movl %ebp,%esp // would like to use "leave" but it's slower - popl %ebp - ret + +#if defined(__linux__) || defined(__APPLE__) + .cfi_startproc +#endif + + pushl %ebp + +#if defined(__linux__) || defined(__APPLE__) + .cfi_def_cfa_offset 8 + .cfi_offset %ebp, -8 +#endif + + movl %esp,%ebp // save esp + +#if defined(__linux__) || defined(__APPLE__) + .cfi_def_cfa_register %ebp +#endif + + movl 16(%ebp),%esp // load new esp + subl $12,%esp // maintain 16-byte alignment + pushl 8(%ebp) // push ptr to argument block + calll *12(%ebp) + movl %ebp,%esp // would like to use "leave" but it's slower + popl %ebp + + ret + +#if defined(__linux__) || defined(__APPLE__) + .cfi_endproc +#endif \ No newline at end of file diff --git a/src/rt/arch/x86_64/ccall.S b/src/rt/arch/x86_64/ccall.S index bfec8fc9795..e74b8677a4a 100644 --- a/src/rt/arch/x86_64/ccall.S +++ b/src/rt/arch/x86_64/ccall.S @@ -13,10 +13,30 @@ _asm_call_on_stack: .globl asm_call_on_stack asm_call_on_stack: #endif - push %rbp - mov %rsp,%rbp // save rsp - mov ARG2,%rsp // switch stack - call *ARG1 // invoke target address - mov %rbp,%rsp - pop %rbp - ret + +#if defined(__linux__) || defined(__APPLE__) + .cfi_startproc +#endif + + push %rbp +#if defined(__linux__) || defined(__APPLE__) + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 +#endif + + mov %rsp,%rbp // save rsp + +#if defined(__linux__) || defined(__APPLE__) + .cfi_def_cfa_register %rbp +#endif + + mov ARG2,%rsp // switch stack + call *ARG1 // invoke target address + mov %rbp,%rsp + pop %rbp + + ret + +#if defined(__linux__) || defined(__APPLE__) + .cfi_endproc +#endif