-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathcorosensei-fix-compilation.patch
225 lines (192 loc) · 8.81 KB
/
corosensei-fix-compilation.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,7 +20,7 @@
libc = { version = "0.2.119", optional = true }
[target.'cfg(windows)'.dependencies]
-windows-sys = { version = "0.33.0", features = [
+windows-sys = { version = "0.59.0", features = [
"Win32_Foundation",
"Win32_System_Diagnostics_Debug",
"Win32_System_Kernel",
--- a/src/arch/x86.rs
+++ b/src/arch/x86.rs
@@ -236,7 +236,7 @@ pub unsafe fn switch_and_link(
// Push a return address onto our stack and then jump to the return
// address at the top of the coroutine stack.
//
- // From here on execution continues in stack_init_trampoline or the 0:
+ // From here on execution continues in stack_init_trampoline or the 3:
// label in switch_yield.
"call [eax]",
@@ -291,7 +291,7 @@ pub unsafe fn switch_yield(arg: EncodedValue, parent_link: *mut StackPointer) ->
// point to "0". We use an intermediate constant here to work around a
// limitation of LLVM's Intel syntax parser which doesn't support 2
// symbols in an expression.
- ".equ .Loffset_yield, 0f - 2b",
+ ".equ .Loffset_yield, 3f - 2b",
"add dword ptr [esp], offset .Loffset_yield",
// Save our stack pointer to EDX, which is then returned out of
@@ -325,7 +325,7 @@ pub unsafe fn switch_yield(arg: EncodedValue, parent_link: *mut StackPointer) ->
// - EAX points to the top of our stack.
// - EDX points to the base of our stack.
// - ECX contains the argument passed from switch_and_link.
- "0:",
+ "3:",
// Save the EBP of the parent context to the parent stack.
"push ebp",
@@ -402,7 +402,7 @@ pub unsafe fn switch_and_throw(
// about how this code works.
"call 2f",
"2:",
- ".equ .Loffset_throw, 0f - 2b",
+ ".equ .Loffset_throw, 3f - 2b",
"add dword ptr [esp], offset .Loffset_throw",
// Save EBP of the parent context.
@@ -437,7 +437,7 @@ pub unsafe fn switch_and_throw(
// Upon returning, our register state is just like a normal return into
// switch_and_link().
- "0:",
+ "3:",
// Restore registers just like the second half of switch_and_link.
"pop esi",
--- a/src/arch/x86_64.rs
+++ b/src/arch/x86_64.rs
@@ -345,7 +345,7 @@ pub unsafe fn switch_and_link(
// Push a return address onto our stack and then jump to the return
// address at the top of the coroutine stack.
//
- // From here on execution continues in stack_init_trampoline or the 0:
+ // From here on execution continues in stack_init_trampoline or the 2:
// label in switch_yield.
"call [rdx]",
@@ -423,7 +423,7 @@ pub unsafe fn switch_yield(arg: EncodedValue, parent_link: *mut StackPointer) ->
// Push a return address on the stack. This is the address that will be
// called by switch_and_link() the next time this context is resumed.
- "lea rax, [rip + 0f]",
+ "lea rax, [rip + 2f]",
"push rax",
// Save our stack pointer to RSI, which is then returned out of
@@ -458,7 +458,7 @@ pub unsafe fn switch_yield(arg: EncodedValue, parent_link: *mut StackPointer) ->
// - RDX points to the top of our stack, including the return address.
// - RSI points to the base of our stack.
// - RDI contains the argument passed from switch_and_link.
- "0:",
+ "2:",
// Save the RBP of the parent context to the parent stack. When combined
// with the return address this forms a valid frame record (RBP & RIP)
@@ -554,7 +554,7 @@ pub unsafe fn switch_and_throw(
"push rbx",
// Push a return address to the stack.
- "lea rax, [rip + 0f]",
+ "lea rax, [rip + 2f]",
"push rax",
// Save RBP of the parent context.
@@ -589,7 +589,7 @@ pub unsafe fn switch_and_throw(
// Upon returning, our register state is just like a normal return into
// switch_and_link().
- "0:",
+ "2:",
// Restore registers just like the second half of switch_and_link.
"pop rbx",
--- a/src/arch/x86_64_windows.rs
+++ b/src/arch/x86_64_windows.rs
@@ -330,7 +330,7 @@ pub unsafe fn switch_and_link(
asm_may_unwind_root!(
// Set up a secondary copy of the return address. This is only used by
// the unwinder, not by actual returns.
- "lea rax, [rip + 0f]",
+ "lea rax, [rip + 2f]",
"push rax",
// Save the TEB fields to the stack.
@@ -345,7 +345,7 @@ pub unsafe fn switch_and_link(
// Push a return address onto our stack and then jump to the return
// address at the top of the coroutine stack.
//
- // From here on execution continues in stack_init_trampoline or the 0:
+ // From here on execution continues in stack_init_trampoline or the 2:
// label in switch_yield.
"call [rdx]",
@@ -354,7 +354,7 @@ pub unsafe fn switch_and_link(
// - RSI: The top of the coroutine stack, or 0 if coming from
// switch_and_reset.
// - RDI: The argument passed from the coroutine.
- "0:",
+ "2:",
"pop rbx",
@@ -405,7 +405,7 @@ pub unsafe fn switch_yield(arg: EncodedValue, parent_link: *mut StackPointer) ->
// Push a return address on the stack. This is the address that will be
// called by switch_and_link() the next time this context is resumed.
- "lea rax, [rip + 0f]",
+ "lea rax, [rip + 2f]",
"push rax",
// Save our stack pointer to RSI, which is then returned out of
@@ -429,7 +429,7 @@ pub unsafe fn switch_yield(arg: EncodedValue, parent_link: *mut StackPointer) ->
// - RDX points to the top of our stack, including the return address.
// - RSI points to the base of our stack.
// - RDI contains the argument passed from switch_and_link.
- "0:",
+ "2:",
// Save RBP from the parent context last to create a valid frame record.
"push rbp",
@@ -513,7 +513,7 @@ pub unsafe fn switch_and_throw(
asm_may_unwind_root!(
// Save state just like the first half of switch_and_link().
- "lea rax, [rip + 0f]",
+ "lea rax, [rip + 2f]",
"push rax",
"push qword ptr gs:[0x1748]", // GuaranteedStackBytes
"push qword ptr gs:[0x1478]", // DeallocationStack
@@ -556,7 +556,7 @@ pub unsafe fn switch_and_throw(
// Upon returning, our register state is just like a normal return into
// switch_and_link().
- "0:",
+ "2",
// This is copied from the second half of switch_and_link().
"pop rbx",
--- a/src/arch/x86_windows.rs
+++ b/src/arch/x86_windows.rs
@@ -411,7 +411,7 @@ pub unsafe fn switch_and_link(
// Push a return address onto our stack and then jump to the return
// address at the top of the coroutine stack.
//
- // From here on execution continues in stack_init_trampoline or the 0:
+ // From here on execution continues in stack_init_trampoline or the 3:
// label in switch_yield.
"call [eax]",
@@ -420,7 +420,6 @@ pub unsafe fn switch_and_link(
// - EDX: The top of the coroutine stack, or 0 if coming from
// switch_and_reset.
// - ECX: The argument passed from the coroutine.
- "0:",
"pop esi",
@@ -480,7 +479,7 @@ pub unsafe fn switch_yield(arg: EncodedValue, parent_link: *mut StackPointer) ->
// point to "0". We use an intermediate constant here to work around a
// limitation of LLVM's Intel syntax parser which doesn't support 2
// symbols in an expression.
- ".equ .Loffset_yield, 0f - 2b",
+ ".equ .Loffset_yield, 3f - 2b",
"add dword ptr [esp], offset .Loffset_yield",
// Save our stack pointer to EDX, which is then returned out of
@@ -514,7 +513,7 @@ pub unsafe fn switch_yield(arg: EncodedValue, parent_link: *mut StackPointer) ->
// - EAX points to the top of our stack.
// - EDX points to the base of our stack.
// - ECX contains the argument passed from switch_and_link.
- "0:",
+ "3:",
// Save the EBP of the parent context to the parent stack.
"push ebp",
@@ -611,7 +610,7 @@ pub unsafe fn switch_and_throw(
// about how this code works.
"call 2f",
"2:",
- ".equ .Loffset_throw, 0f - 2b",
+ ".equ .Loffset_throw, 3f - 2b",
"add dword ptr [esp], offset .Loffset_throw",
// Save EBP of the parent context.
@@ -645,7 +644,7 @@ pub unsafe fn switch_and_throw(
// Upon returning, our register state is just like a normal return into
// switch_and_link().
- "0:",
+ "3:",
// This is copied from the second half of switch_and_link().
"pop esi",