diff options
| author | David Crawshaw <crawshaw@golang.org> | 2015-04-10 13:07:04 -0400 |
|---|---|---|
| committer | David Crawshaw <crawshaw@golang.org> | 2015-04-12 12:49:49 +0000 |
| commit | 6e3a6c4d384bb1ca532727bbd7a1cd221786c42a (patch) | |
| tree | d3d4b398a4c4b2cb3cbe3e23a2b5c51822f77ce7 /src | |
| parent | 922a412822e4f103334634e7350d02a7f8d07069 (diff) | |
| download | go-6e3a6c4d384bb1ca532727bbd7a1cd221786c42a.tar.xz | |
runtime: library entry point for darwin/arm
Tested by using -buildmode=c-archive to generate an archive, add it
to an Xcode project and calling a Go function from an iOS app. (I'm
still investigating proper buildmode tests for all.bash.)
Change-Id: I7890df15246df8e90ad27837b8d64ba2cde409fe
Reviewed-on: https://go-review.googlesource.com/8719
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/runtime/rt0_darwin_arm.s | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/runtime/rt0_darwin_arm.s b/src/runtime/rt0_darwin_arm.s index 4d31e3a78a..95a2b179c4 100644 --- a/src/runtime/rt0_darwin_arm.s +++ b/src/runtime/rt0_darwin_arm.s @@ -11,6 +11,47 @@ TEXT _rt0_arm_darwin(SB),7,$-4 MOVW $main(SB), R4 B (R4) +// When linking with -buildmode=c-archive or -buildmode=c-shared, +// this symbol is called from a global initialization function. +// +// Note that all currently shipping darwin/arm platforms require +// cgo and do not support c-shared. +TEXT _rt0_arm_darwin_lib(SB),NOSPLIT,$12 + MOVW R0, _rt0_arm_darwin_lib_argc<>(SB) + MOVW R1, _rt0_arm_darwin_lib_argv<>(SB) + + // Create a new thread to do the runtime initialization and return. + MOVW _cgo_sys_thread_create(SB), R4 + CMP $0, R4 + B.EQ nocgo + MOVW $_rt0_arm_darwin_lib_go(SB), R0 + MOVW $0, R1 + BL (R4) + RET +nocgo: + MOVW $0x400000, R0 + MOVW $_rt0_arm_darwin_lib_go(SB), R1 + MOVW $0, R2 + MOVW R0, (R13) // stacksize + MOVW R1, 4(R13) // fn + MOVW R2, 8(R13) // fnarg + MOVW $runtime·newosproc0(SB), R4 + BL (R4) + RET + +TEXT _rt0_arm_darwin_lib_go(SB),NOSPLIT,$0 + MOVW _rt0_arm_darwin_lib_argc<>(SB), R0 + MOVW _rt0_arm_darwin_lib_argv<>(SB), R1 + MOVW R0, (R13) + MOVW R1, 4(R13) + MOVW $runtime·rt0_go(SB), R4 + B (R4) + +DATA _rt0_arm_darwin_lib_argc<>(SB)/4, $0 +GLOBL _rt0_arm_darwin_lib_argc<>(SB),NOPTR, $4 +DATA _rt0_arm_darwin_lib_argv<>(SB)/4, $0 +GLOBL _rt0_arm_darwin_lib_argv<>(SB),NOPTR, $4 + TEXT main(SB),NOSPLIT,$-8 // save argc and argv onto stack MOVM.DB.W [R0-R1], (R13) |
