Skip to content

Commit a0eb531

Browse files
committed
liblink: fix $0 frame size
The previous logic was confused, because it assumed p->to.offset was purely the desired frame size, whereas we encode in the high word unspecified args size as 0x80000000. The logic infered that every function with unspecified args size was a leaf. Fixes golang#40
1 parent 4175998 commit a0eb531

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/liblink/obj7.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -400,16 +400,16 @@ addstacksplit(Link *ctxt, LSym *cursym)
400400
switch(o) {
401401
case ATEXT:
402402
cursym->text = p;
403-
if(p->to.offset < 0)
403+
if(textstksiz < 0)
404404
ctxt->autosize = 0;
405405
else
406-
ctxt->autosize = p->to.offset + 8;
406+
ctxt->autosize = textstksiz + 8;
407407
if(((cursym->text->mark & LEAF)) && ctxt->autosize <= 8)
408408
ctxt->autosize = 0;
409409
else
410410
if(ctxt->autosize & ((16 - 1)))
411411
ctxt->autosize += 16 - ((ctxt->autosize & ((16 - 1))));
412-
p->to.offset = ctxt->autosize - 8;
412+
p->to.offset = (p->to.offset & (0xffffffffull<<32)) | (uint32)(ctxt->autosize-8);
413413
if(ctxt->autosize == 0 && !((cursym->text->mark & LEAF))) {
414414
if(ctxt->debugvlog)
415415
Bprint(ctxt->bso, "save suppressed in: %s\n", cursym->text->from.sym->name);

0 commit comments

Comments
 (0)