Commit ed575dc2 authored by Ken Thompson's avatar Ken Thompson

bug in stack size in arm.

stack is off by one if calling
through reflect.Call

R=rsc
CC=golang-dev
https://golang.org/cl/2400041
parent 3f032d56
...@@ -94,7 +94,7 @@ TEXT breakpoint(SB),7,$0 ...@@ -94,7 +94,7 @@ TEXT breakpoint(SB),7,$0
// uintptr gosave(Gobuf*) // uintptr gosave(Gobuf*)
// save state in Gobuf; setjmp // save state in Gobuf; setjmp
TEXT gosave(SB), 7, $-4 TEXT gosave(SB), 7, $-4
MOVW 0(FP), R0 MOVW 0(FP), R0 // gobuf
MOVW SP, gobuf_sp(R0) MOVW SP, gobuf_sp(R0)
MOVW LR, gobuf_pc(R0) MOVW LR, gobuf_pc(R0)
MOVW g, gobuf_g(R0) MOVW g, gobuf_g(R0)
...@@ -116,12 +116,14 @@ TEXT gogo(SB), 7, $-4 ...@@ -116,12 +116,14 @@ TEXT gogo(SB), 7, $-4
// (call fn, returning to state in Gobuf) // (call fn, returning to state in Gobuf)
// using frame size $-4 means do not save LR on stack. // using frame size $-4 means do not save LR on stack.
TEXT gogocall(SB), 7, $-4 TEXT gogocall(SB), 7, $-4
MOVW 0(FP), R0 MOVW 0(FP), R0 // gobuf
MOVW 4(FP), R1 // fn MOVW 4(FP), R1 // fn
MOVW 8(FP), R2 // fp offset
MOVW gobuf_g(R0), g MOVW gobuf_g(R0), g
MOVW 0(g), R2 // make sure g != nil MOVW 0(g), R3 // make sure g != nil
MOVW gobuf_sp(R0), SP // restore SP MOVW gobuf_sp(R0), SP // restore SP
MOVW gobuf_pc(R0), LR MOVW gobuf_pc(R0), LR
SUB R2, SP
MOVW R1, PC MOVW R1, PC
/* /*
......
...@@ -528,7 +528,7 @@ scheduler(void) ...@@ -528,7 +528,7 @@ scheduler(void)
m->curg = gp; m->curg = gp;
gp->m = m; gp->m = m;
if(gp->sched.pc == (byte*)goexit) // kickoff if(gp->sched.pc == (byte*)goexit) // kickoff
gogocall(&gp->sched, (void(*)(void))gp->entry); gogocall(&gp->sched, (void(*)(void))gp->entry, 0);
gogo(&gp->sched, 1); gogo(&gp->sched, 1);
} }
...@@ -797,7 +797,7 @@ newstack(void) ...@@ -797,7 +797,7 @@ newstack(void)
label.sp = sp; label.sp = sp;
label.pc = (byte*)·lessstack; label.pc = (byte*)·lessstack;
label.g = m->curg; label.g = m->curg;
gogocall(&label, m->morepc); gogocall(&label, m->morepc, 4);
*(int32*)345 = 123; // never return *(int32*)345 = 123; // never return
} }
......
...@@ -377,7 +377,7 @@ int32 charntorune(int32*, uint8*, int32); ...@@ -377,7 +377,7 @@ int32 charntorune(int32*, uint8*, int32);
* very low level c-called * very low level c-called
*/ */
void gogo(Gobuf*, uintptr); void gogo(Gobuf*, uintptr);
void gogocall(Gobuf*, void(*)(void)); void gogocall(Gobuf*, void(*)(void), int64);
uintptr gosave(Gobuf*); uintptr gosave(Gobuf*);
void ·lessstack(void); void ·lessstack(void);
void goargs(void); void goargs(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment