aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_linux_arm.s
diff options
context:
space:
mode:
authorSrdjan Petrovic <spetrovic@google.com>2015-04-03 09:40:10 -0700
committerDavid Crawshaw <crawshaw@golang.org>2015-04-13 18:58:18 +0000
commit93644c9118dfcd5c7b46d22fbe6b7f1cb1f1b696 (patch)
tree1a6b7fc7a3522c54793192ea99675ab26489c49c /src/runtime/sys_linux_arm.s
parentfdab2f92eab01e8aca980c76cba18c2361cb0fc7 (diff)
downloadgo-93644c9118dfcd5c7b46d22fbe6b7f1cb1f1b696.tar.xz
runtime: shared library runtime init for arm
Adds the runtime initialization flow for arm akin to amd64. In particular,we use the library initialization entry point to: - create a new OS thread and run the "regular" runtime init stack on that thread - return immediately from the main (i.e., loader) thread - at the first CGO invocation, we wait for the runtime initialization to complete. Verified to work on a Raspberry Pi and an Android phone. Change-Id: I32f39228ae30a03ce9569287f234b305790fecf6 Reviewed-on: https://go-review.googlesource.com/8455 Reviewed-by: David Crawshaw <crawshaw@golang.org> Run-TryBot: Srdjan Petrovic <spetrovic@google.com>
Diffstat (limited to 'src/runtime/sys_linux_arm.s')
-rw-r--r--src/runtime/sys_linux_arm.s37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/runtime/sys_linux_arm.s b/src/runtime/sys_linux_arm.s
index db9fcb90cf..d422f95f08 100644
--- a/src/runtime/sys_linux_arm.s
+++ b/src/runtime/sys_linux_arm.s
@@ -310,12 +310,43 @@ TEXT runtime·clone(SB),NOSPLIT,$0
MOVW R0, (R1)
// int32 clone0(int32 flags, void *stack, void* fn, void* fnarg);
-TEXT runtime·clone0(SB),NOSPLIT,$0
- // TODO(spetrovic): Implement this method.
- MOVW $-1, R0
+TEXT runtime·clone0(SB),NOSPLIT,$0-20
+ MOVW flags+0(FP), R0
+ MOVW stack+4(FP), R1
+ // Update child's future stack and save fn and fnarg on it.
+ MOVW $-8(R1), R1
+ MOVW fn+8(FP), R6
+ MOVW R6, 0(R1)
+ MOVW fnarg+12(FP), R6
+ MOVW R6, 4(R1)
+ MOVW $0, R2 // parent tid ptr
+ MOVW $0, R3 // tls_val
+ MOVW $0, R4 // child tid ptr
+ MOVW $0, R5
+ MOVW $SYS_clone, R7
+ SWI $0
+
+ // In parent, return.
+ CMP $0, R0
+ BEQ 3(PC)
MOVW R0, ret+16(FP)
RET
+ // In child.
+ MOVW 0(R13), R6 // fn
+ MOVW 4(R13), R0 // fnarg
+ MOVW $8(R13), R13
+ BL (R6)
+
+ MOVW $0, R0
+ MOVW R0, 4(R13)
+ BL runtime·exit1(SB)
+
+ // It shouldn't return
+ MOVW $1234, R0
+ MOVW $1005, R1
+ MOVW R0, (R1)
+
TEXT runtime·sigaltstack(SB),NOSPLIT,$0
MOVW new+0(FP), R0
MOVW old+4(FP), R1