diff --git a/sdk/lib/crt/setjmp/amd64/setjmp.s b/sdk/lib/crt/setjmp/amd64/setjmp.s index c105c7c7cdf..7720118be0d 100644 --- a/sdk/lib/crt/setjmp/amd64/setjmp.s +++ b/sdk/lib/crt/setjmp/amd64/setjmp.s @@ -59,11 +59,10 @@ FUNC _setjmp mov [rcx + JUMP_BUFFER_R14], r14 /* Store r14 */ mov [rcx + JUMP_BUFFER_R15], r15 /* Store r15 */ - lea rax, [rip + SJRET] /* Get the return address (see SJRET below) */ - mov [rcx + JUMP_BUFFER_Rip], rax /* Store rip (return address) */ + mov [rcx + JUMP_BUFFER_Frame], ebp /* Store frame pointer (ebp) */ - mov rax, [rsp + 8] /* Get frame pointer */ - mov [rcx + JUMP_BUFFER_Frame], rax /* Store frame pointer */ + lea rax, [esp + 8] /* Get the return address */ + mov [rcx + JUMP_BUFFER_Rip], rax /* Store rip (return address) */ movdqu [rcx + JUMP_BUFFER_Xmm6], xmm6 /* Store xmm6 */ movdqu [rcx + JUMP_BUFFER_Xmm7], xmm7 /* Store xmm7 */ @@ -76,8 +75,7 @@ FUNC _setjmp movdqu [rcx + JUMP_BUFFER_Xmm14], xmm14 /* Store xmm14 */ movdqu [rcx + JUMP_BUFFER_Xmm15], xmm15 /* Store xmm15 */ - xor eax, eax /* Return 0 on first (_setjmp) return */ -SJRET: + xor rax, rax /* Return 0 on first (_setjmp) return */ ret ENDFUNC @@ -104,10 +102,10 @@ FUNC _setjmpex mov [rcx + JUMP_BUFFER_R14], r14 /* Store r14 */ mov [rcx + JUMP_BUFFER_R15], r15 /* Store r15 */ - lea rax, [rip + SJXRET] /* Get the return address (see SJXRET below) */ - mov [rcx + JUMP_BUFFER_Rip], rax /* Store rip (return address) */ + mov [rcx + JUMP_BUFFER_Frame], rdx /* Store frame pointer (rdx) */ - mov [rcx + JUMP_BUFFER_Frame], rdx /* Store frame */ + lea rax, [esp + 8] /* Get the return address */ + mov [rcx + JUMP_BUFFER_Rip], rax /* Store rip (return address) */ movdqu [rcx + JUMP_BUFFER_Xmm6], xmm6 /* Store xmm6 */ movdqu [rcx + JUMP_BUFFER_Xmm7], xmm7 /* Store xmm7 */ @@ -120,9 +118,7 @@ FUNC _setjmpex movdqu [rcx + JUMP_BUFFER_Xmm14], xmm14 /* Store xmm14 */ movdqu [rcx + JUMP_BUFFER_Xmm15], xmm15 /* Store xmm15 */ - xor eax, eax /* Return 0 on first (_setjmpex) return */ - -SJXRET: + xor rax, rax /* Return 0 on first (_setjmpex) return */ ret ENDFUNC @@ -150,8 +146,7 @@ FUNC longjmp mov r14, [rcx + JUMP_BUFFER_R14] /* Restore r14 */ mov r15, [rcx + JUMP_BUFFER_R15] /* Restore r15 */ - mov rax, [rcx + JUMP_BUFFER_Frame] /* Get frame pointer */ - mov [rsp + 8], rax /* Restore frame pointer */ + mov ebp, [rcx + JUMP_BUFFER_Frame] /* Get frame pointer (ebp) */ movdqu xmm6, [rcx + JUMP_BUFFER_Xmm6] /* Restore xmm6 */ movdqu xmm7, [rcx + JUMP_BUFFER_Xmm7] /* Restore xmm7 */ @@ -164,15 +159,17 @@ FUNC longjmp movdqu xmm14, [rcx + JUMP_BUFFER_Xmm14] /* Restore xmm14 */ movdqu xmm15, [rcx + JUMP_BUFFER_Xmm15] /* Restore xmm15 */ - mov rax, rdx /* Move val into rax (return value) */ + mov rax, [rcx + JUMP_BUFFER_Rip] /* Get return address */ + mov [esp + 8], rax /* Store return address */ + mov rax, rdx /* Move val into rax (return value) */ test rax, rax /* Check if val is 0 */ jnz LJJMP /* If val is non-zero, jump to LJJMP */ inc rax /* Increment rax */ LJJMP: - jmp qword ptr [rcx + JUMP_BUFFER_Rip] /* Jump to the stored return address (rip) */ + ret ENDFUNC END