Commit d9557523 authored by Russ Cox's avatar Russ Cox

runtime: make framepointer mode safe for Windows

A few other architectures have already defined a NOFRAME flag.
Use it to disable frame pointer code on a few very low-level functions
that must behave like Windows code.

Makes the failing os/signal test pass on a Windows gomote.

Change-Id: I982365f2c59a0aa302b4428c970846c61027cf3e
Reviewed-on: https://go-review.googlesource.com/23456Reviewed-by: default avatarAustin Clements <austin@google.com>
parent 805eaeef
...@@ -610,12 +610,11 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -610,12 +610,11 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
} }
var bpsize int var bpsize int
if p.Mode == 64 && obj.Framepointer_enabled != 0 && autoffset > 0 { if p.Mode == 64 && obj.Framepointer_enabled != 0 && autoffset > 0 && p.From3.Offset&obj.NOFRAME == 0 {
// Make room for to save a base pointer. If autoffset == 0, // Make room for to save a base pointer. If autoffset == 0,
// this might do something special like a tail jump to // this might do something special like a tail jump to
// another function, so in that case we omit this. // another function, so in that case we omit this.
bpsize = ctxt.Arch.PtrSize bpsize = ctxt.Arch.PtrSize
autoffset += int32(bpsize) autoffset += int32(bpsize)
p.To.Offset += int64(bpsize) p.To.Offset += int64(bpsize)
} else { } else {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#define maxargs 16 #define maxargs 16
// void runtime·asmstdcall(void *c); // void runtime·asmstdcall(void *c);
TEXT runtime·asmstdcall(SB),NOSPLIT,$0 TEXT runtime·asmstdcall(SB),NOSPLIT|NOFRAME,$0
// asmcgocall will put first argument into CX. // asmcgocall will put first argument into CX.
PUSHQ CX // save for later PUSHQ CX // save for later
MOVQ libcall_fn(CX), AX MOVQ libcall_fn(CX), AX
...@@ -62,7 +62,7 @@ loadregs: ...@@ -62,7 +62,7 @@ loadregs:
RET RET
TEXT runtime·badsignal2(SB),NOSPLIT,$48 TEXT runtime·badsignal2(SB),NOSPLIT|NOFRAME,$48
// stderr // stderr
MOVQ $-12, CX // stderr MOVQ $-12, CX // stderr
MOVQ CX, 0(SP) MOVQ CX, 0(SP)
...@@ -102,7 +102,7 @@ TEXT runtime·setlasterror(SB),NOSPLIT,$0 ...@@ -102,7 +102,7 @@ TEXT runtime·setlasterror(SB),NOSPLIT,$0
// exception record and context pointers. // exception record and context pointers.
// Handler function is stored in AX. // Handler function is stored in AX.
// Return 0 for 'not handled', -1 for handled. // Return 0 for 'not handled', -1 for handled.
TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 TEXT runtime·sigtramp(SB),NOSPLIT|NOFRAME,$0-0
// CX: PEXCEPTION_POINTERS ExceptionInfo // CX: PEXCEPTION_POINTERS ExceptionInfo
// DI SI BP BX R12 R13 R14 R15 registers and DF flag are preserved // DI SI BP BX R12 R13 R14 R15 registers and DF flag are preserved
...@@ -190,32 +190,32 @@ done: ...@@ -190,32 +190,32 @@ done:
RET RET
TEXT runtime·exceptiontramp(SB),NOSPLIT,$0 TEXT runtime·exceptiontramp(SB),NOSPLIT|NOFRAME,$0
MOVQ $runtime·exceptionhandler(SB), AX MOVQ $runtime·exceptionhandler(SB), AX
JMP runtime·sigtramp(SB) JMP runtime·sigtramp(SB)
TEXT runtime·firstcontinuetramp(SB),NOSPLIT,$0-0 TEXT runtime·firstcontinuetramp(SB),NOSPLIT|NOFRAME,$0-0
MOVQ $runtime·firstcontinuehandler(SB), AX MOVQ $runtime·firstcontinuehandler(SB), AX
JMP runtime·sigtramp(SB) JMP runtime·sigtramp(SB)
TEXT runtime·lastcontinuetramp(SB),NOSPLIT,$0-0 TEXT runtime·lastcontinuetramp(SB),NOSPLIT|NOFRAME,$0-0
MOVQ $runtime·lastcontinuehandler(SB), AX MOVQ $runtime·lastcontinuehandler(SB), AX
JMP runtime·sigtramp(SB) JMP runtime·sigtramp(SB)
TEXT runtime·ctrlhandler(SB),NOSPLIT,$8 TEXT runtime·ctrlhandler(SB),NOSPLIT|NOFRAME,$8
MOVQ CX, 16(SP) // spill MOVQ CX, 16(SP) // spill
MOVQ $runtime·ctrlhandler1(SB), CX MOVQ $runtime·ctrlhandler1(SB), CX
MOVQ CX, 0(SP) MOVQ CX, 0(SP)
CALL runtime·externalthreadhandler(SB) CALL runtime·externalthreadhandler(SB)
RET RET
TEXT runtime·profileloop(SB),NOSPLIT,$8 TEXT runtime·profileloop(SB),NOSPLIT|NOFRAME,$8
MOVQ $runtime·profileloop1(SB), CX MOVQ $runtime·profileloop1(SB), CX
MOVQ CX, 0(SP) MOVQ CX, 0(SP)
CALL runtime·externalthreadhandler(SB) CALL runtime·externalthreadhandler(SB)
RET RET
TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0 TEXT runtime·externalthreadhandler(SB),NOSPLIT|NOFRAME,$0
PUSHQ BP PUSHQ BP
MOVQ SP, BP MOVQ SP, BP
PUSHQ BX PUSHQ BX
...@@ -228,7 +228,7 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0 ...@@ -228,7 +228,7 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0
SUBQ $m__size, SP // space for M SUBQ $m__size, SP // space for M
MOVQ SP, 0(SP) MOVQ SP, 0(SP)
MOVQ $m__size, 8(SP) MOVQ $m__size, 8(SP)
CALL runtime·memclr(SB) // smashes AX,BX,CX CALL runtime·memclr(SB) // smashes AX,BX,CX, maybe BP
LEAQ m_tls(SP), CX LEAQ m_tls(SP), CX
MOVQ CX, 0x28(GS) MOVQ CX, 0x28(GS)
...@@ -239,7 +239,7 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0 ...@@ -239,7 +239,7 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0
MOVQ SP, 0(SP) MOVQ SP, 0(SP)
MOVQ $g__size, 8(SP) MOVQ $g__size, 8(SP)
CALL runtime·memclr(SB) // smashes AX,BX,CX CALL runtime·memclr(SB) // smashes AX,BX,CX, maybe BP
LEAQ g__size(SP), BX LEAQ g__size(SP), BX
MOVQ BX, g_m(SP) MOVQ BX, g_m(SP)
...@@ -430,7 +430,7 @@ ret: ...@@ -430,7 +430,7 @@ ret:
// Runs on OS stack. duration (in 100ns units) is in BX. // Runs on OS stack. duration (in 100ns units) is in BX.
// The function leaves room for 4 syscall parameters // The function leaves room for 4 syscall parameters
// (as per windows amd64 calling convention). // (as per windows amd64 calling convention).
TEXT runtime·usleep2(SB),NOSPLIT,$48 TEXT runtime·usleep2(SB),NOSPLIT|NOFRAME,$48
MOVQ SP, AX MOVQ SP, AX
ANDQ $~15, SP // alignment as per Windows requirement ANDQ $~15, SP // alignment as per Windows requirement
MOVQ AX, 40(SP) MOVQ AX, 40(SP)
...@@ -446,7 +446,7 @@ TEXT runtime·usleep2(SB),NOSPLIT,$48 ...@@ -446,7 +446,7 @@ TEXT runtime·usleep2(SB),NOSPLIT,$48
RET RET
// Runs on OS stack. // Runs on OS stack.
TEXT runtime·switchtothread(SB),NOSPLIT,$0 TEXT runtime·switchtothread(SB),NOSPLIT|NOFRAME,$0
MOVQ SP, AX MOVQ SP, AX
ANDQ $~15, SP // alignment as per Windows requirement ANDQ $~15, SP // alignment as per Windows requirement
SUBQ $(48), SP // room for SP and 4 args as per Windows requirement SUBQ $(48), SP // room for SP and 4 args as per Windows requirement
......
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