x86_64 redzone
Samuel Thibault
samuel.thibault@eu.citrix.com
Thu Nov 8 16:50:00 GMT 2007
Hi,
We are using newlib embedded in a small kernel that runs on x86_64. We
have a problem with the red zone because the interrupts just use the
current stack. I hence had to compile newlib with -mno-red-zone and
use the patch below. Could there be a newlib --no-red-zone option or
something similar that would do this?
Samuel
Index: newlib/libc/machine/x86_64/memcpy.S
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/x86_64/memcpy.S,v
retrieving revision 1.1
diff -u -p -r1.1 memcpy.S
--- newlib/libc/machine/x86_64/memcpy.S 28 Aug 2007 21:56:49 -0000 1.1
+++ newlib/libc/machine/x86_64/memcpy.S 8 Nov 2007 16:32:44 -0000
@@ -30,10 +30,18 @@ quadword_aligned:
cmpq $256, rdx
jb quadword_copy
+#if 1
+ subq $32, rsp
+ movq rax, 24 (rsp)
+ movq r12, 16 (rsp)
+ movq r13, 8 (rsp)
+ movq r14, 0 (rsp)
+#else
movq rax, -8 (rsp)
movq r12, -16 (rsp)
movq r13, -24 (rsp)
movq r14, -32 (rsp)
+#endif
movq rdx, rcx /* Copy 128 bytes at a time with minimum cache polution */
shrq $7, rcx
@@ -89,10 +97,18 @@ loop:
movq rdx, rcx
andq $127, rcx
rep movsb
+#if 1
+ movq 24 (rsp), rax
+ movq 16 (rsp), r12
+ movq 8 (rsp), r13
+ movq 0 (rsp), r14
+ addq $32, rsp
+#else
movq -8 (rsp), rax
movq -16 (rsp), r12
movq -24 (rsp), r13
movq -32 (rsp), r14
+#endif
ret
More information about the Newlib
mailing list