aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/rt0_linux_arm.s
diff options
context:
space:
mode:
authorElias Naur <elias.naur@gmail.com>2016-05-16 15:51:07 +0200
committerElias Naur <elias.naur@gmail.com>2016-05-25 06:54:28 +0000
commit72eb46c5a086051e3677579a0810922724eb6a6d (patch)
tree511b1c4afd76a504a3e69bfbb927ed6f89357ace /src/runtime/rt0_linux_arm.s
parentfa3f484800415662cc741bbb8968ebb72896e20a (diff)
downloadgo-72eb46c5a086051e3677579a0810922724eb6a6d.tar.gz
go-72eb46c5a086051e3677579a0810922724eb6a6d.zip
runtime,runtime/cgo: save callee-saved FP register on arm
Other GOARCHs already handle their callee-saved FP registers, but arm was missing. Without this change, code using Cgo and floating point code might fail in mysterious and hard to debug ways. There are no floating point registers when GOARM=5, so skip the registers when runtime.goarm < 6. darwin/arm doesn't support GOARM=5, so the check is left out of rt0_darwin_arm.s. Fixes #14876 Change-Id: I6bcb90a76df3664d8ba1f33123a74b1eb2c9f8b2 Reviewed-on: https://go-review.googlesource.com/23140 Run-TryBot: Elias Naur <elias.naur@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Minux Ma <minux@golang.org>
Diffstat (limited to 'src/runtime/rt0_linux_arm.s')
-rw-r--r--src/runtime/rt0_linux_arm.s27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/runtime/rt0_linux_arm.s b/src/runtime/rt0_linux_arm.s
index a4419b898e..597e642adb 100644
--- a/src/runtime/rt0_linux_arm.s
+++ b/src/runtime/rt0_linux_arm.s
@@ -12,7 +12,7 @@ TEXT _rt0_arm_linux(SB),NOSPLIT,$-4
// When building with -buildmode=c-shared, this symbol is called when the shared
// library is loaded.
-TEXT _rt0_arm_linux_lib(SB),NOSPLIT,$32
+TEXT _rt0_arm_linux_lib(SB),NOSPLIT,$104
// Preserve callee-save registers. Raspberry Pi's dlopen(), for example,
// actually cares that R11 is preserved.
MOVW R4, 12(R13)
@@ -22,6 +22,19 @@ TEXT _rt0_arm_linux_lib(SB),NOSPLIT,$32
MOVW R8, 28(R13)
MOVW R11, 32(R13)
+ // Skip floating point registers on GOARM < 6.
+ MOVB runtime·goarm(SB), R11
+ CMP $6, R11
+ BLT skipfpsave
+ MOVD F8, (32+8*1)(R13)
+ MOVD F9, (32+8*2)(R13)
+ MOVD F10, (32+8*3)(R13)
+ MOVD F11, (32+8*4)(R13)
+ MOVD F12, (32+8*5)(R13)
+ MOVD F13, (32+8*6)(R13)
+ MOVD F14, (32+8*7)(R13)
+ MOVD F15, (32+8*8)(R13)
+skipfpsave:
// Save argc/argv.
MOVW R0, _rt0_arm_linux_lib_argc<>(SB)
MOVW R1, _rt0_arm_linux_lib_argv<>(SB)
@@ -46,6 +59,18 @@ nocgo:
BL runtime·newosproc0(SB)
rr:
// Restore callee-save registers and return.
+ MOVB runtime·goarm(SB), R11
+ CMP $6, R11
+ BLT skipfprest
+ MOVD (32+8*1)(R13), F8
+ MOVD (32+8*2)(R13), F9
+ MOVD (32+8*3)(R13), F10
+ MOVD (32+8*4)(R13), F11
+ MOVD (32+8*5)(R13), F12
+ MOVD (32+8*6)(R13), F13
+ MOVD (32+8*7)(R13), F14
+ MOVD (32+8*8)(R13), F15
+skipfprest:
MOVW 12(R13), R4
MOVW 16(R13), R5
MOVW 20(R13), R6