diff options
author | Elias Naur <elias.naur@gmail.com> | 2016-03-12 12:13:11 +0100 |
---|---|---|
committer | Elias Naur <elias.naur@gmail.com> | 2016-03-15 08:43:34 +0000 |
commit | ea4b785ae03a067f4a26adac78213ff6caac5128 (patch) | |
tree | 860bd32217830b22b7b83077d3caa09aecc71d8d /src/runtime/rt0_darwin_arm64.s | |
parent | ac47f66abcd98cc5f0e121691acd3e8dced09b4b (diff) | |
download | go-ea4b785ae03a067f4a26adac78213ff6caac5128.tar.gz go-ea4b785ae03a067f4a26adac78213ff6caac5128.zip |
runtime: preserve darwin/arm{,64} callee-save registers
CL 14603 attempted to preserve the callee-save registers for
the darwin/arm runtime initialization routine, but I believe it
wasn't sufficient and resulted in the crash reported in issue
Saving and restoring the registers on the stack the same way
linux/arm does seems more obvious and fixes #14778, so do that.
Even though #14778 is not reproducible on darwin/arm64, I applied
a similar change there, and to linux/arm64 which obeys the same
calling convention.
Finally, this CL is a candidate for a 1.6 minor release for the same
reason CL 14603 was in a 1.5 minor release (as CL 16968). It is
small and only touches the iOS platforms and gomobile on darwin/arm
is currently useless without it.
Fixes #14778
Fixes #12590 (again)
Change-Id: I7401daf0bbd7c579a7e84761384a7b763651752a
Reviewed-on: https://go-review.googlesource.com/20621
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/rt0_darwin_arm64.s')
-rw-r--r-- | src/runtime/rt0_darwin_arm64.s | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/runtime/rt0_darwin_arm64.s b/src/runtime/rt0_darwin_arm64.s index fa676c0abe..0a1feb14a4 100644 --- a/src/runtime/rt0_darwin_arm64.s +++ b/src/runtime/rt0_darwin_arm64.s @@ -16,12 +16,17 @@ TEXT _rt0_arm64_darwin(SB),NOSPLIT,$-8 // // Note that all currently shipping darwin/arm64 platforms require // cgo and do not support c-shared. -TEXT _rt0_arm64_darwin_lib(SB),NOSPLIT,$0 - // R27 is REGTMP, reserved for liblink. It is used below to - // move R0/R1 into globals. However in the standard ARM64 calling - // convention, it is a callee-saved register. So we save it to a - // temporary register. - MOVD R27, R7 +TEXT _rt0_arm64_darwin_lib(SB),NOSPLIT,$88 + // Preserve callee-save registers. + MOVD R19, 24(RSP) + MOVD R20, 32(RSP) + MOVD R21, 40(RSP) + MOVD R22, 48(RSP) + MOVD R23, 56(RSP) + MOVD R24, 64(RSP) + MOVD R25, 72(RSP) + MOVD R26, 80(RSP) + MOVD R27, 88(RSP) MOVD R0, _rt0_arm64_darwin_lib_argc<>(SB) MOVD R1, _rt0_arm64_darwin_lib_argv<>(SB) @@ -36,7 +41,16 @@ TEXT _rt0_arm64_darwin_lib(SB),NOSPLIT,$0 MOVD $0, R1 BL (R4) - MOVD R7, R27 + // Restore callee-save registers. + MOVD 24(RSP), R19 + MOVD 32(RSP), R20 + MOVD 40(RSP), R21 + MOVD 48(RSP), R22 + MOVD 56(RSP), R23 + MOVD 64(RSP), R24 + MOVD 72(RSP), R25 + MOVD 80(RSP), R26 + MOVD 88(RSP), R27 RET TEXT _rt0_arm64_darwin_lib_go(SB),NOSPLIT,$0 |