diff options
author | Russ Cox <rsc@golang.org> | 2014-08-14 15:29:37 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-08-14 15:29:37 -0400 |
commit | ba1d77eb933aeb8962ba1eb097ae7442e7ea6ecd (patch) | |
tree | 5e74a72a5cc6a803d9d2cf1267cb40da287cb38d /src/cmd/ld/lib.c | |
parent | 0d325017a5e61d732b4f42e79f14b780f3b882f1 (diff) | |
download | go-ba1d77eb933aeb8962ba1eb097ae7442e7ea6ecd.tar.gz |
[dev.power64] cmd/ld, runtime: detect, fix nosplit overflows
LGTM=minux
R=minux
CC=golang-codereviews
https://codereview.appspot.com/121690043
Diffstat (limited to 'src/cmd/ld/lib.c')
-rw-r--r-- | src/cmd/ld/lib.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c index b4134da36..5db41f9a7 100644 --- a/src/cmd/ld/lib.c +++ b/src/cmd/ld/lib.c @@ -1026,7 +1026,7 @@ static LSym *newstack; enum { - HasLinkRegister = (thechar == '5'), + HasLinkRegister = (thechar == '5' || thechar == '9'), }; // TODO: Record enough information in new object files to @@ -1035,7 +1035,7 @@ enum static int callsize(void) { - if(thechar == '5') + if(HasLinkRegister) return 0; return RegSize; } @@ -1046,9 +1046,6 @@ dostkcheck(void) Chain ch; LSym *s; - if(thechar == '9') - return; - morestack = linklookup(ctxt, "runtime.morestack", 0); newstack = linklookup(ctxt, "runtime.newstack", 0); @@ -1072,19 +1069,19 @@ dostkcheck(void) continue; if(s->nosplit) { - ctxt->cursym = s; - ch.sym = s; - stkcheck(&ch, 0); - } + ctxt->cursym = s; + ch.sym = s; + stkcheck(&ch, 0); + } } for(s = ctxt->textp; s != nil; s = s->next) { if(!s->nosplit) { - ctxt->cursym = s; - ch.sym = s; - stkcheck(&ch, 0); + ctxt->cursym = s; + ch.sym = s; + stkcheck(&ch, 0); + } } } -} static int stkcheck(Chain *up, int depth) @@ -1102,7 +1099,7 @@ stkcheck(Chain *up, int depth) // function at top of safe zone once. if(limit == StackLimit-callsize()) { if(s->stkcheck) - return 0; + return 0; s->stkcheck = 1; } @@ -1161,8 +1158,8 @@ stkcheck(Chain *up, int depth) // to StackLimit beyond the frame size. if(strncmp(r->sym->name, "runtime.morestack", 17) == 0) { limit = StackLimit + s->locals; - if(thechar == '5') - limit += 4; // saved LR + if(HasLinkRegister) + limit += RegSize; } break; @@ -1181,7 +1178,7 @@ stkcheck(Chain *up, int depth) break; } } - } + } return 0; } @@ -1210,7 +1207,7 @@ stkprint(Chain *ch, int limit) else print("\t%d\tguaranteed after split check in %s\n", ch->limit, name); } else { - stkprint(ch->up, ch->limit + (!HasLinkRegister)*PtrSize); + stkprint(ch->up, ch->limit + (!HasLinkRegister)*RegSize); if(!HasLinkRegister) print("\t%d\ton entry to %s\n", ch->limit, name); } |