Hi all,

Please find the attached patch which adds an ARM64 stub for the _sigfe_maybe 
routine
in the gendef script.

Any feedback or nits are very welcome. The changes are documented with inline
comments intended to be self-explanatory. please let me know if any part
of this patch should be adjusted.

Thanks for your time and review.

Thanks & regards
Thirumalai Nagalingam <[email protected]>

In-lined patch:

diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef
index 1419704b8..52a5b77ca 100755
--- a/winsup/cygwin/scripts/gendef
+++ b/winsup/cygwin/scripts/gendef
@@ -367,8 +367,24 @@ EOF
        .include "tlsoffsets"
        .text

-_sigfe_maybe:
-       .global _sigbe
+       .seh_proc _sigfe_maybe
+_sigfe_maybe:                                  # stack is aligned on entry!
+       .seh_endprologue
+       ldr     x10, [x18, #0x8]                // Load TEB pointer in x10
+       ldr     x11, =_cygtls.initialized       // Load relative offset of 
_cygtls.initialized
+       add     x11, x10, x11                   // compute absolute address and 
store in x11
+       cmp     sp, x11                         // Compare current stack 
pointer with TLS location
+       b.hs    0f                              // if sp >= tls, skip TLS logic
+       ldr     w12, [x11]                      // Load the value at 
_cygtls.initialized (32-bit)
+       movz    w13, #0xc763                    // Prepare magic 
value(0xc763173f) lower 16 bits
+       movk    w13, #0x173f, lsl #16           // Add upper 16 bits, full 
value now in w13
+       cmp     w12, w13                        // Compare loaded value with 
magic
+       b.ne    0f                              // If not equal, not 
initialized, skip TLS logic
+       ret
+0:
+       ret
+       .seh_endproc
+
 _sigfe:
 _sigbe:
        .global sigdelayed
--

Attachment: 0002-Cygwin-gendef-add-_sigfe_maybe-for-TLS-initializatio.patch
Description: 0002-Cygwin-gendef-add-_sigfe_maybe-for-TLS-initializatio.patch

Reply via email to