From ced760b64147d6c9e41619dd1c51626ff770d9ad Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 4 Mar 2010 15:34:25 -0800 Subject: cc: disallow ... argument unless NOSPLIT is set. check that NOSPLIT functions don't use too much stack. correct some missing NOSPLITs in the runtime library. Fixes bug reported in https://groups.google.com/group/golang-nuts/t/efff68b73941eccf R=ken2 CC=golang-dev http://codereview.appspot.com/236041 --- src/cmd/5c/sgen.c | 10 +++++++++- src/cmd/6c/sgen.c | 8 ++++++-- src/cmd/8c/sgen.c | 10 +++++++++- src/cmd/cc/pgen.c | 1 + 4 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/5c/sgen.c b/src/cmd/5c/sgen.c index 1584ecff3..92a0f64f8 100644 --- a/src/cmd/5c/sgen.c +++ b/src/cmd/5c/sgen.c @@ -34,9 +34,17 @@ Prog* gtext(Sym *s, int32 stkoff) { + int32 a; + + a = 0; + if(!(textflag & NOSPLIT)) + a = argsize(); + else if(stkoff >= 128) + yyerror("stack frame too large for NOSPLIT function"); + gpseudo(ATEXT, s, nodconst(stkoff)); p->to.type = D_CONST2; - p->to.offset2 = argsize(); + p->to.offset2 = a; return p; } diff --git a/src/cmd/6c/sgen.c b/src/cmd/6c/sgen.c index 1a5987f09..b8247a1b7 100644 --- a/src/cmd/6c/sgen.c +++ b/src/cmd/6c/sgen.c @@ -34,9 +34,13 @@ Prog* gtext(Sym *s, int32 stkoff) { vlong v; - - v = argsize() << 32; + + v = 0; + if(!(textflag & NOSPLIT)) + v |= argsize() << 32; v |= stkoff & 0xffffffff; + if((textflag & NOSPLIT) && stkoff >= 128) + yyerror("stack frame too large for NOSPLIT function"); gpseudo(ATEXT, s, nodgconst(v, types[TVLONG])); return p; diff --git a/src/cmd/8c/sgen.c b/src/cmd/8c/sgen.c index c4f91987c..b0f2bc544 100644 --- a/src/cmd/8c/sgen.c +++ b/src/cmd/8c/sgen.c @@ -33,9 +33,17 @@ Prog* gtext(Sym *s, int32 stkoff) { + int32 a; + + a = 0; + if(!(textflag & NOSPLIT)) + a = argsize(); + else if(stkoff >= 128) + yyerror("stack frame too large for NOSPLIT function"); + gpseudo(ATEXT, s, nodconst(stkoff)); p->to.type = D_CONST2; - p->to.offset2 = argsize(); + p->to.offset2 = a; return p; } diff --git a/src/cmd/cc/pgen.c b/src/cmd/cc/pgen.c index d430ec91b..cd6fffc57 100644 --- a/src/cmd/cc/pgen.c +++ b/src/cmd/cc/pgen.c @@ -43,6 +43,7 @@ argsize(void) case TVOID: break; case TDOT: + yyerror("function takes ... without textflag NOSPLIT"); s += 64; break; default: -- cgit v1.2.3