在 2026-11-9 21:54, LIU Hao 写道:
I tried looking into these patches for some times, but these are, nonetheless, a very complicated series of changes. So far I consider to take these piece by piece. The first two seem quite obvious. I can push them tomorrow.
For patch 1 and 2, one issue is that the second parameter of `longjmp()` is `int`, so you should use `edx`/`w1` for 64-bit code. Old code has `mov rax,rdx`/`mov x0,x1` which has the same effect, but with these changes it's not equivalent any more, since the upper half of the incoming argument is indeterminate.
I have pushed patch 1 and 2 (of 25 total) with this change (32-bit targets are
unchanged):
diff --git a/mingw-w64-crt/misc/longjmp.S b/mingw-w64-crt/misc/longjmp.S
index a7f04d529..65aaedca9 100644
--- a/mingw-w64-crt/misc/longjmp.S
+++ b/mingw-w64-crt/misc/longjmp.S
@@ -24,9 +24,9 @@ __MINGW_USYMBOL(longjmp):
addl $4,%esp /* get rid of return address */
jmp *20(%ecx) /* jmp_buf.Eip */
#elif defined(__x86_64__)
- movq %rdx,%rax /* retval */
- cmpq $1,%rax /* check that retval is non-zero */
- adcq $0,%rax /* if not then increase by one via CF */
+ movl %edx,%eax /* retval */
+ cmpl $1,%eax /* check that retval is non-zero */
+ adcl $0,%eax /* if not then increase by one via CF */
movq 0x8(%rcx),%rbx /* jmp_buf->Rbx */
movq 0x18(%rcx),%rbp /* jmp_buf->Rbp */
movq 0x20(%rcx),%rsi /* jmp_buf->Rsi */
@@ -94,8 +94,8 @@ __MINGW_USYMBOL(longjmp):
ldp d10, d11, [x0, #0x90] /* jmp_buf->D[2-3] */
ldp d12, d13, [x0, #0xa0] /* jmp_buf->D[4-5] */
ldp d14, d15, [x0, #0xb0] /* jmp_buf->D[6-7] */
- cmp x1, #1
- csinc x0, x1, xzr, hi /* retval */
+ cmp w1, #1
+ csinc w0, w1, wzr, hi /* retval */
ret
#endif
diff --git a/mingw-w64-crt/misc/mingw_longjmp.S
b/mingw-w64-crt/misc/mingw_longjmp.S
index 5863f0d88..cb5cc6613 100644
--- a/mingw-w64-crt/misc/mingw_longjmp.S
+++ b/mingw-w64-crt/misc/mingw_longjmp.S
@@ -102,8 +102,8 @@ __MINGW_USYMBOL(__mingw_longjmp):
ldp d10, d11, [x0, #0x90] /* jmp_buf->D[2-3] */
ldp d12, d13, [x0, #0xa0] /* jmp_buf->D[4-5] */
ldp d14, d15, [x0, #0xb0] /* jmp_buf->D[6-7] */
- cmp x1, #1
- csinc x0, x1, xzr, hi /* retval */
+ cmp w1, #1
+ csinc w0, w1, wzr, hi /* retval */
ret
#endif
#endif
--
Best regards,
LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
