Skip to content

Commit def610a

Browse files
committed
Use ecx/rcx to restore entrypoint after call to __guard_check_icall_fptr
1 parent 26833ef commit def610a

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

lib/Backend/NativeCodeGenerator.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,10 +1495,9 @@ NativeCodeGenerator::CheckAsmJsCodeGenThunk(Js::RecyclableObject* function, Js::
14951495
call NativeCodeGenerator::CheckAsmJsCodeGen
14961496
#ifdef _CONTROL_FLOW_GUARD
14971497
// verify that the call target is valid
1498-
push eax
14991498
mov ecx, eax
15001499
call[__guard_check_icall_fptr]
1501-
pop eax
1500+
mov eax, ecx
15021501
#endif
15031502
pop ebp
15041503
jmp eax
@@ -1524,10 +1523,9 @@ NativeCodeGenerator::CheckCodeGenThunk(Js::RecyclableObject* function, Js::CallI
15241523
call NativeCodeGenerator::CheckCodeGen
15251524
#ifdef _CONTROL_FLOW_GUARD
15261525
// verify that the call target is valid
1527-
push eax
15281526
mov ecx, eax
15291527
call[__guard_check_icall_fptr]
1530-
pop eax
1528+
mov eax, ecx
15311529
#endif
15321530
pop ebp
15331531
jmp eax

lib/Runtime/Language/InterpreterStackFrame.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,10 +1612,9 @@ namespace Js
16121612
skipThunk:
16131613
#ifdef _CONTROL_FLOW_GUARD
16141614
// verify that the call target is valid
1615-
push eax;
16161615
mov ecx, eax;
16171616
call[__guard_check_icall_fptr];
1618-
pop eax;
1617+
mov eax, ecx;
16191618
#endif
16201619

16211620
pop ebp;
@@ -1636,10 +1635,9 @@ namespace Js
16361635

16371636
#ifdef _CONTROL_FLOW_GUARD
16381637
// verify that the call target is valid
1639-
push eax;
16401638
mov ecx, eax;
16411639
call[__guard_check_icall_fptr];
1642-
pop eax;
1640+
mov eax, ecx;
16431641
#endif
16441642

16451643
pop ebp;

lib/Runtime/Language/JavascriptExceptionOperators.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,10 +917,9 @@ namespace Js
917917

918918
#if 0 && defined(_CONTROL_FLOW_GUARD)
919919
// verify that the call target is valid
920-
mov ebx, eax; save call target
921920
mov ecx, eax
922921
call[__guard_check_icall_fptr]
923-
mov eax, ebx; restore call target
922+
mov eax, ecx; restore call target
924923
#endif
925924

926925
// save the current frame ptr, and adjust the frame to access

lib/Runtime/Library/JavascriptFunction.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,14 +1204,13 @@ using namespace Js;
12041204
mov ecx, argsSize;
12051205
rep movs byte ptr[edi], byte ptr[esi];
12061206

1207+
mov ecx, entryPoint
12071208
#ifdef _CONTROL_FLOW_GUARD
12081209
// verify that the call target is valid
1209-
mov ecx, entryPoint
12101210
call[__guard_check_icall_fptr]
1211-
; no need to restore ecx('call entryPoint' is a __cdecl call)
12121211
#endif
12131212
push function;
1214-
call entryPoint;
1213+
call ecx;
12151214
mov retVals.low, eax;
12161215
mov retVals.high, edx;
12171216
movaps retVals.xmm, xmm0;
@@ -1297,16 +1296,15 @@ void __cdecl _alloca_probe_16()
12971296
// call variable argument function provided in entryPoint
12981297
__asm
12991298
{
1299+
mov ecx, entryPoint
13001300
#ifdef _CONTROL_FLOW_GUARD
13011301
// verify that the call target is valid
1302-
mov ecx, entryPoint
13031302
call [__guard_check_icall_fptr]
1304-
; no need to restore ecx ('call entryPoint' is a __cdecl call)
13051303
#endif
13061304

13071305
push callInfo
13081306
push function
1309-
call entryPoint
1307+
call ecx
13101308

13111309
// Restore ESP
13121310
mov esp, savedEsp

0 commit comments

Comments
 (0)