Index: lib/builtins/CMakeLists.txt =================================================================== --- lib/builtins/CMakeLists.txt +++ lib/builtins/CMakeLists.txt @@ -444,6 +444,7 @@ endif() set(aarch64_SOURCES + aarch64/chkstk_darwin.S ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES}) Index: lib/builtins/aarch64/chkstk_darwin.S =================================================================== --- /dev/null +++ lib/builtins/aarch64/chkstk_darwin.S @@ -0,0 +1,33 @@ +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. + +#include "../assembly.h" + +#ifdef __aarch64__ + +#define PAGE_SZ 4096 + +// ___chkstk_darwin - a generic stack probing function. +// The number of bytes to probe is passed in w9. +// This clobbers registers x9, x10 and x11. +// Does not modify any memory or the stack pointer + +.balign 4 +DEFINE_COMPILERRT_FUNCTION(___chkstk_darwin) +.weak_definition ___chkstk_darwin + cmp w9, #PAGE_SZ + mov x10, sp + b.lo Lend +Lloop: + sub x10, x10, #PAGE_SZ + ldr x11, [x10] + sub w9, w9, #PAGE_SZ + cmp w9, #PAGE_SZ + b.hi Lloop +Lend: + sub x10, x10, x9 + ldr x11, [x10] + ret +END_COMPILERRT_FUNCTION(___chkstk_darwin) + +#endif // __aarch64__ Index: lib/builtins/assembly.h =================================================================== --- lib/builtins/assembly.h +++ lib/builtins/assembly.h @@ -18,6 +18,8 @@ #if defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__) #define SEPARATOR @ +#elif defined(__aarch64__) +#define SEPARATOR %% #else #define SEPARATOR ; #endif