aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShenghou Ma <minux@golang.org>2016-02-18 16:29:39 -0500
committerAndrew Gerrand <adg@golang.org>2016-04-14 05:20:45 +0000
commit8624a53c50d6c955501a14b480c799cf71c21718 (patch)
tree44015afa6001eebc5bdae17742ecc05dfa2a0346
parent512261e50e90c7fb064b825c7fab67e95a3142ab (diff)
downloadgo-8624a53c50d6c955501a14b480c799cf71c21718.tar.gz
go-8624a53c50d6c955501a14b480c799cf71c21718.zip
runtime: use correct psABI SP alignment before calling libc mmap
Fixes #14384. Change-Id: Ib025cf2d20754b4c2db52f0a8a4717fd303371d6 Reviewed-on: https://go-review.googlesource.com/19660 Run-TryBot: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-on: https://go-review.googlesource.com/22037
-rw-r--r--src/runtime/sys_linux_amd64.s6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s
index aed85cb0aa..f407078176 100644
--- a/src/runtime/sys_linux_amd64.s
+++ b/src/runtime/sys_linux_amd64.s
@@ -258,7 +258,7 @@ TEXT runtime·sysMmap(SB),NOSPLIT,$0
// Call the function stored in _cgo_mmap using the GCC calling convention.
// This must be called on the system stack.
-TEXT runtime·callCgoMmap(SB),NOSPLIT,$0
+TEXT runtime·callCgoMmap(SB),NOSPLIT,$16
MOVQ addr+0(FP), DI
MOVQ n+8(FP), SI
MOVL prot+16(FP), DX
@@ -266,7 +266,11 @@ TEXT runtime·callCgoMmap(SB),NOSPLIT,$0
MOVL fd+24(FP), R8
MOVL off+28(FP), R9
MOVQ _cgo_mmap(SB), AX
+ MOVQ SP, BX
+ ANDQ $~15, SP // alignment as per amd64 psABI
+ MOVQ BX, 0(SP)
CALL AX
+ MOVQ 0(SP), SP
MOVQ AX, ret+32(FP)
RET