Skip to content

Commit

Permalink
runtime: make stack 16-byte aligned for external code in _rt0_amd64_l…
Browse files Browse the repository at this point in the history
…inux_lib

Fixes golang#16618.

Change-Id: Iffada12e8672bbdbcf2e787782c497e2c45701b1
Reviewed-on: https://go-review.googlesource.com/25550
Run-TryBot: Minux Ma <[email protected]>
Reviewed-by: Arjan Van De Ven <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
minux committed Aug 5, 2016
1 parent 9fde86b commit 26015b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/runtime/rt0_linux_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ TEXT _rt0_amd64_linux(SB),NOSPLIT,$-8

// When building with -buildmode=c-shared, this symbol is called when the shared
// library is loaded.
TEXT _rt0_amd64_linux_lib(SB),NOSPLIT,$0x48
// Note: This function calls external C code, which might required 16-byte stack
// alignment after cmd/internal/obj applies its transformations.
TEXT _rt0_amd64_linux_lib(SB),NOSPLIT,$0x50
MOVQ SP, AX
ANDQ $-16, SP
MOVQ BX, 0x10(SP)
MOVQ BP, 0x18(SP)
MOVQ R12, 0x20(SP)
MOVQ R13, 0x28(SP)
MOVQ R14, 0x30(SP)
MOVQ R15, 0x38(SP)
MOVQ AX, 0x40(SP)

MOVQ DI, _rt0_amd64_linux_lib_argc<>(SB)
MOVQ SI, _rt0_amd64_linux_lib_argv<>(SB)
Expand Down Expand Up @@ -50,6 +55,7 @@ restore:
MOVQ 0x28(SP), R13
MOVQ 0x30(SP), R14
MOVQ 0x38(SP), R15
MOVQ 0x40(SP), SP
RET

TEXT _rt0_amd64_linux_lib_go(SB),NOSPLIT,$0
Expand Down

0 comments on commit 26015b9

Please sign in to comment.