Skip to content

Commit 2469fbe

Browse files
committed
Preserve ebp in stackman_switch, win_x86. Do not compile runtime checks in c-wrapper.
1 parent aaec1be commit 2469fbe

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

lib/win_x86/stackman.lib

-2.22 KB
Binary file not shown.

src/platforms/switch_x86_msvc.asm

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
.code
66

77
stackman_switch_raw PROC callback:DWORD, context:DWORD
8-
8+
;Assembler has already pushed the basepointer and saved it.
99
;save registers. EAX ECX and EDX are available for function use and thus
1010
;do not have to be stored.
1111
push ebx
1212
push esi
1313
push edi
14-
push ebp
1514
1615
mov esi, callback ; /* save 'callback' for later */
1716
mov edi, context ; /* save 'context' for later */
@@ -22,16 +21,20 @@ stackman_switch_raw PROC callback:DWORD, context:DWORD
2221
push 0; /* arg 2: opcode STACKMAN_OP_SAVE */
2322
push edi ; /* arg 1: context */
2423
call esi ; /* call callback() */
25-
26-
mov esp, eax; /* change the stack pointer */
24+
add esp, 12;
25+
26+
mov ecx, eax; /* change stack pointer to eax, preserving */
27+
sub ecx, esp; /* base pointer offset from esp */
28+
mov esp, eax;
29+
add ebp, ecx;
30+
2731

2832
push eax ; /* arg 3: current (new) stack pointer */
2933
push 1; /* arg 2: opcode STACKMAN_OP_RESTORE */
3034
push edi ; /* arg 1: context */
3135
call esi ; /* call callback() */
3236
add esp, 12
3337

34-
pop ebp
3538
pop edi
3639
pop esi
3740
pop ebx

vs2019/stackman/stackman.vcxproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@
175175
<ClInclude Include="..\..\src\stackman_switch.h" />
176176
</ItemGroup>
177177
<ItemGroup>
178-
<ClCompile Include="..\..\src\stackman.c" />
178+
<ClCompile Include="..\..\src\stackman.c">
179+
<SupportJustMyCode Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</SupportJustMyCode>
180+
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Default</BasicRuntimeChecks>
181+
</ClCompile>
179182
<ClCompile Include="template.c">
180183
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AssemblyCode</AssemblerOutput>
181184
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">AssemblyCode</AssemblerOutput>
@@ -199,10 +202,14 @@
199202
<MARMASM Include="..\..\src\platforms\switch_arm_msvc.asm">
200203
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</ExcludedFromBuild>
201204
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
205+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
206+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
202207
</MARMASM>
203208
<MARMASM Include="..\..\src\platforms\switch_arm64_msvc.asm">
204209
<FileType>Document</FileType>
205210
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
211+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
212+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
206213
</MARMASM>
207214
<MASM Include="..\..\src\platforms\switch_x64_msvc.asm">
208215
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>

0 commit comments

Comments
 (0)