Skip to content

Commit 87a51a0

Browse files
committed
runtime: save r11 in ARM addmoduledata
R11 is callee-save in the C ABI, but the temporary register in the Go ABI. Currently it's being clobbered by runtime.addmoduledata, which has to follow the C ABI. The observed effect of this was that dl_open_worker was returning to a bad PC because after it failed to restore its SP because it was using R11 as a frame pointer. Fix this by saving R11 around addmoduledata. Fixes #19674. Change-Id: Iaacbcc76809a3aa536e9897770831dcbcb6c8245 Reviewed-on: https://go-review.googlesource.com/47831 Run-TryBot: Austin Clements <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent c027ecf commit 87a51a0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/runtime/asm_arm.s

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,11 +1011,13 @@ TEXT runtime·sigreturn(SB),NOSPLIT,$0-0
10111011

10121012
#ifndef GOOS_nacl
10131013
// This is called from .init_array and follows the platform, not Go, ABI.
1014-
TEXT runtime·addmoduledata(SB),NOSPLIT,$0-4
1014+
TEXT runtime·addmoduledata(SB),NOSPLIT,$0-8
10151015
MOVW R9, saver9-4(SP) // The access to global variables below implicitly uses R9, which is callee-save
1016+
MOVW R11, saver11-8(SP) // Likewise, R11 is the temp register, but callee-save in C ABI
10161017
MOVW runtime·lastmoduledatap(SB), R1
10171018
MOVW R0, moduledata_next(R1)
10181019
MOVW R0, runtime·lastmoduledatap(SB)
1020+
MOVW saver11-8(SP), R11
10191021
MOVW saver9-4(SP), R9
10201022
RET
10211023
#endif

0 commit comments

Comments
 (0)