From d65aa994f7ac9db9496baae5c3df15b708d1c277 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 20 Nov 2010 13:03:11 +0000 Subject: [PATCH] [CRT] Implement __alloca_probe_16 svn path=/branches/cmake-bringup/; revision=49660 --- lib/sdk/crt/except/i386/chkstk_asm.s | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/sdk/crt/except/i386/chkstk_asm.s b/lib/sdk/crt/except/i386/chkstk_asm.s index 80c9b7317f8..58879f18d0f 100644 --- a/lib/sdk/crt/except/i386/chkstk_asm.s +++ b/lib/sdk/crt/except/i386/chkstk_asm.s @@ -14,8 +14,37 @@ PUBLIC __chkstk PUBLIC __alloca_probe +PUBLIC __alloca_probe_16 .code + /* 16 byte aligned alloca probe + * EAX = size to be allocated */ +__alloca_probe_16: + /* save the ECX register */ + push ecx + + /* ecx = top of the previous stack frame */ + lea ecx, [esp + 8] + + /* Calculate end of allocation */ + sub ecx, eax + + /* Get the misalignment */ + and ecx, 15 + + /* Add the misalignment to the original alloc size */ + add eax, ecx + + /* Check for overflow */ + jnc l1 + + /* Set maximum value */ + mov eax, HEX(0ffffffff) +l1: + /* Restore ecx */ + pop ecx + /* Fall through to __chkstk */ + /* _chkstk() is called by all stack allocations of more than 4 KB. It grows the stack in areas of 4 KB each, trying to access each area. This ensures that the