Mercurial > hg > tinycc
changeset 454:fec6eca7c4d7
Patch from Zdenek Pavlas, affects PE target:
> Because of Windows' draconic handling of page faults 'sub esp, 4096' is
> a no-no. Rare functions needing page or more of stack space must call
> chkstk(stacksize) first. TCC needs 10 bytes for such call while the
> standard function prolog was only 9 so it pads them to 10 bytes.
>
> This patch uses a shorter chkstk() calling convention that fits in 9
> bytes so no more padding.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 16 May 2007 20:04:21 -0400 |
parents | a70ac19d704b |
children | 3e7c64539eb2 |
files | i386/i386-gen.c win32/lib/chkstk.S |
diffstat | 2 files changed, 3 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/i386/i386-gen.c Sat May 12 19:43:33 2007 -0400 +++ b/i386/i386-gen.c Wed May 16 20:04:21 2007 -0400 @@ -407,11 +407,7 @@ vtop--; } -#ifdef TCC_TARGET_PE -#define FUNC_PROLOG_SIZE 10 -#else #define FUNC_PROLOG_SIZE 9 -#endif /* generate function prolog of type 't' */ void gfunc_prolog(CType *func_type) @@ -541,7 +537,6 @@ #ifdef TCC_TARGET_PE if (v >= 4096) { Sym *sym = external_global_sym(TOK___chkstk, &func_old_type, 0); - oad(0xb8, v); /* mov stacksize, %eax */ oad(0xe8, -4); /* call __chkstk, (does the stackframe too) */ greloc(cur_text_section, sym, ind-4, R_386_PC32); } else @@ -549,11 +544,8 @@ { o(0xe58955); /* push %ebp, mov %esp, %ebp */ o(0xec81); /* sub esp, stacksize */ - gen_le32(v); -#if FUNC_PROLOG_SIZE == 10 - o(0x90); /* adjust to FUNC_PROLOG_SIZE */ -#endif } + gen_le32(v); ind = saved_ind; }
--- a/win32/lib/chkstk.S Sat May 12 19:43:33 2007 -0400 +++ b/win32/lib/chkstk.S Wed May 16 20:04:21 2007 -0400 @@ -6,6 +6,8 @@ __chkstk: xchg (%esp), %ebp // store ebp, get ret.addr + mov (%ebp), %eax // get stacksize + lea 4(%ebp), %ebp // skip it push %ebp // push ret.addr lea 4(%esp), %ebp // setup frame ptr push %ecx // save ecx