Path: blob/master/libs/compiler-rt/lib/builtins/i386/chkstk2.S
12349 views
// This file is dual licensed under the MIT and the University of Illinois Open1// Source Licenses. See LICENSE.TXT for details.23#include "../assembly.h"45#ifdef __i386__67// _chkstk (_alloca) routine - probe stack between %esp and (%esp-%eax) in 4k increments,8// then decrement %esp by %eax. Preserves all registers except %esp and flags.9// This routine is windows specific10// http://msdn.microsoft.com/en-us/library/ms648426.aspx1112.text13.balign 414DEFINE_COMPILERRT_FUNCTION(_alloca) // _chkstk and _alloca are the same function15DEFINE_COMPILERRT_FUNCTION(__chkstk)16push %ecx17cmp $0x1000,%eax18lea 8(%esp),%ecx // esp before calling this routine -> ecx19jb 1f202:21sub $0x1000,%ecx22test %ecx,(%ecx)23sub $0x1000,%eax24cmp $0x1000,%eax25ja 2b261:27sub %eax,%ecx28test %ecx,(%ecx)2930lea 4(%esp),%eax // load pointer to the return address into eax31mov %ecx,%esp // install the new top of stack pointer into esp32mov -4(%eax),%ecx // restore ecx33push (%eax) // push return address onto the stack34sub %esp,%eax // restore the original value in eax35ret36END_COMPILERRT_FUNCTION(__chkstk)37END_COMPILERRT_FUNCTION(_alloca)3839#endif // __i386__404142