Nina@26: Nina@26: //Assembly code takes the return addr off the stack and saves Nina@26: // into the singleton. The first field in the singleton is the Nina@26: // "endInstrAddr" field, and the return addr is at 0x4(%ebp) Nina@26: .globl asm_save_ret_to_singleton Nina@26: asm_save_ret_to_singleton: Nina@26: movq 0x8(%rbp), %rax #get ret address, ebp is the same as in the calling function Nina@26: movq %rax, (%rdi) #write ret addr to endInstrAddr field Nina@26: ret Nina@26: Nina@26: Nina@26: //Assembly code changes the return addr on the stack to the one Nina@26: // saved into the singleton by the end-singleton-fn Nina@26: //The stack's return addr is at 0x4(%%ebp) Nina@26: .globl asm_write_ret_from_singleton Nina@26: asm_write_ret_from_singleton: Nina@26: movq (%rdi), %rax #get endInstrAddr field Nina@26: movq %rax, 0x8(%rbp) #write return addr to the stack of the caller Nina@26: ret Nina@26: Nina@26: