Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
[x86/Linux] Fix PAL unit test paltest_pal_sxs_test1
Browse files Browse the repository at this point in the history
Fix unit test error for x86/Linux
- fix fail of exception_handling/pal_sxs/test1/paltest_pal_sxs_test1
  • Loading branch information
seanshpark committed Dec 8, 2016
1 parent 957b6d9 commit 8393632
Showing 1 changed file with 71 additions and 3 deletions.
74 changes: 71 additions & 3 deletions src/pal/src/arch/i386/context2.S
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,76 @@ LEAF_ENTRY RtlCaptureContext, _TEXT
mov eax, [esp + 8]
mov DWORD PTR [eax + CONTEXT_ContextFlags], (CONTEXT_FLOATING_POINT)
pop eax
jmp C_FUNC(CONTEXT_CaptureContext)
ret

//jmp C_FUNC(CONTEXT_CaptureContext)
// Store
push eax
push ebx

// The stack will contain the following elements on the top of
// the caller's stack
// [ebx] / esp + 00
// [eax] / esp + 04
// [ret] / esp + 08
// [arg0: lpContext] / esp + 12

mov eax, [esp + 12] // eax will point to lpContext

// Capture INTEGER registers
mov ebx, [esp + 4]
mov [eax + CONTEXT_Eax], ebx
mov ebx, [esp]
mov [eax + CONTEXT_Ebx], ebx
mov [eax + CONTEXT_Ecx], ecx
mov [eax + CONTEXT_Edx], edx
mov [eax + CONTEXT_Esi], esi
mov [eax + CONTEXT_Edi], edi

// Capture CONTROL registers
mov [eax + CONTEXT_Ebp], ebp
lea ebx, [esp + 12]
mov [eax + CONTEXT_Esp], ebx
mov ebx, [esp + 8]
mov [eax + CONTEXT_Eip], ebx

push cs
xor ebx, ebx
pop bx
mov [eax + CONTEXT_SegCs], ebx

push ss
xor ebx, ebx
pop bx
mov [eax + CONTEXT_SegSs], ebx

pushf
xor ebx, ebx
pop bx
mov [eax + CONTEXT_EFlags], ebx

test BYTE PTR [eax + CONTEXT_ContextFlags], CONTEXT_FLOATING_POINT
je LOCAL_LABEL(Done_CONTEXT_FLOATING_POINT2)
// Capture FPU status
fnsave [eax + CONTEXT_FloatSave]
frstor [eax + CONTEXT_FloatSave]
LOCAL_LABEL(Done_CONTEXT_FLOATING_POINT2):

test BYTE PTR [eax + CONTEXT_ContextFlags], CONTEXT_EXTENDED_REGISTERS
je LOCAL_LABEL(Done_CONTEXT_EXTENDED_REGISTERS2)
movdqu [eax + CONTEXT_Xmm0], xmm0
movdqu [eax + CONTEXT_Xmm1], xmm1
movdqu [eax + CONTEXT_Xmm2], xmm2
movdqu [eax + CONTEXT_Xmm3], xmm3
movdqu [eax + CONTEXT_Xmm4], xmm4
movdqu [eax + CONTEXT_Xmm5], xmm5
movdqu [eax + CONTEXT_Xmm6], xmm6
movdqu [eax + CONTEXT_Xmm7], xmm7
LOCAL_LABEL(Done_CONTEXT_EXTENDED_REGISTERS2):

// Restore
pop ebx
pop eax
ret 4
LEAF_END RtlCaptureContext, _TEXT

LEAF_ENTRY RtlRestoreContext, _TEXT
Expand Down Expand Up @@ -147,6 +215,6 @@ LOCAL_LABEL(Done_Restore_CONTEXT_EXTENDED_REGISTERS):
pop esi
pop edi

ret
ret 8
LEAF_END RtlRestoreContext, _TEXT

0 comments on commit 8393632

Please sign in to comment.