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