Hi all, This patch is not for review and a V2 is upcoming.
The current version contains a few known issues that have already been fixed by Igor Podgainoi <[email protected]<mailto:[email protected]>>. Those fixes will be contributed directly by Igor by a V2 patch, which will be posted to this same thread. Notes: Attached is a patch that adds an ARM64 stub for the `setjmp` routine in the gendef script. The changes are documented with inline comments and should be self-explanatory. I would also like to thank Radek BartoĊ <[email protected]<mailto:[email protected]>> for his initial contributions to this effort. Thanks & regards Thirumalai Nagalingam <[email protected]<mailto:[email protected]>> In-lined patch: diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef index 0b2d3db9b..5ad7fd947 100755 --- a/winsup/cygwin/scripts/gendef +++ b/winsup/cygwin/scripts/gendef @@ -706,7 +706,62 @@ sigsetjmp: .seh_endproc .globl setjmp + .seh_proc setjmp setjmp: + // prologue + stp fp, lr, [sp, #-0x10]! // push frame pointer (x29) and link register (x30) + mov fp, sp // set frame pointer + .seh_endprologue + + // save callee-saved registers from jump buffer + stp x19, x20, [x0, #0x08] // save x19, x20 + stp x21, x22, [x0, #0x18] // save x21, x22 + stp x23, x24, [x0, #0x28] // save x23, x24 + stp x25, x26, [x0, #0x38] // save x25, x26 + stp x27, x28, [x0, #0x48] // save x27, x28 + stp x29, x30, [x0, #0x58] // save frame ptr (x29) and return addr (x30) + + mov x1, sp // get the current stack pointer + str x1, [x0, #0x68] // save SP + + mrs x1, fpcr // get fp control register + str x1, [x0, #0x70] // save FPCR + mrs x1, fpsr // get fp status register + str x1, [x0, #0x78] // save FPSR + + // save fp registers (d8-d15) + stp d8, d9, [x0, #0x80] // save d8, d9 + stp d10, d11, [x0, #0x90] // save d10, d11 + stp d12, d13, [x0, #0xA0] // save d12, d13 + stp d14, d15, [x0, #0xB0] // save d14, d15 + + mov x9, x0 // save jmp_buf pointer in x9 + # // save TLS stack pointer + # ldr x1, [sp] + # str x1, [x0, #0xB8] + + bl stabilize_sig_stack // call stabilize_sig_stack (returns TLS in x0) + + // store the stack pointer to jump_buf + ldr x2, =_cygtls.stackptr // load the symbol address/offset + add x2, x0, x2 // Final address of stackptr + ldr x3, [x2] // load current value of stackptr + str x3, [x0, #0xB8] // store stackptr into jmp_buf + + // decrement the stack lock + ldr x2, =_cygtls.stacklock // load the symbol address/offset + add x2, x0, x2 // Final address of stacklock + ldr w3, [x2] // load current stacklock value + sub w3, w3, #1 // decrement + str w3, [x2] //store back + + mov w0, #0 // return 0 + + // epilogue + ldp fp, lr, [sp], #0x10 // restore saved FP and LR registers + ret + .seh_endproc + .globl siglongjmp .seh_proc siglongjmp siglongjmp:
Cygwin-gendef-Implement-setjmp-for-AArch64.patch
Description: Cygwin-gendef-Implement-setjmp-for-AArch64.patch
