From: Jacek Caban <jacek@codeweavers.com> --- libs/compiler-rt/Makefile.in | 1 + .../compiler-rt/lib/builtins/aarch64/chkstk.S | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 libs/compiler-rt/lib/builtins/aarch64/chkstk.S diff --git a/libs/compiler-rt/Makefile.in b/libs/compiler-rt/Makefile.in index 85757c21a47..48f6762158f 100644 --- a/libs/compiler-rt/Makefile.in +++ b/libs/compiler-rt/Makefile.in @@ -1,6 +1,7 @@ STATICLIB = libcompiler-rt.a SOURCES = \ + lib/builtins/aarch64/chkstk.S \ lib/builtins/arm/aeabi_idivmod.S \ lib/builtins/arm/aeabi_ldivmod.S \ lib/builtins/arm/aeabi_uidivmod.S \ diff --git a/libs/compiler-rt/lib/builtins/aarch64/chkstk.S b/libs/compiler-rt/lib/builtins/aarch64/chkstk.S new file mode 100644 index 00000000000..0a92e3057d0 --- /dev/null +++ b/libs/compiler-rt/lib/builtins/aarch64/chkstk.S @@ -0,0 +1,40 @@ +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. + +#include "../assembly.h" + +// __chkstk routine +// This routine is windows specific. +// http://msdn.microsoft.com/en-us/library/ms648426.aspx + +// This clobbers registers x16 and x17. +// Does not modify any memory or the stack pointer. + +// mov x15, #256 // Number of bytes of stack, in units of 16 byte +// bl __chkstk +// sub sp, sp, x15, lsl #4 + +#if defined(__aarch64__) || defined(__arm64ec__) + +#ifdef __arm64ec__ +#define CHKSTK_FUNC __chkstk_arm64ec +#else +#define CHKSTK_FUNC __chkstk +#endif + +#define PAGE_SIZE 4096 + + .p2align 2 +DEFINE_COMPILERRT_FUNCTION(CHKSTK_FUNC) + lsl x16, x15, #4 + mov x17, sp +1: + sub x17, x17, #PAGE_SIZE + subs x16, x16, #PAGE_SIZE + ldr xzr, [x17] + b.gt 1b + + ret +END_COMPILERRT_FUNCTION(CHKSTK_FUNC) + +#endif // defined(__aarch64__) || defined(__arm64ec__) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10184