diff options
author | David Crawshaw <crawshaw@golang.org> | 2015-10-27 19:47:54 -0400 |
---|---|---|
committer | David Crawshaw <crawshaw@golang.org> | 2015-10-28 21:21:33 +0000 |
commit | 73ff7cb1ed56921c82bf6bdfc173ce8e49ea437c (patch) | |
tree | eaba967dec5b59bd75ae67d1cdcc572f42a06717 /src/runtime/rt0_linux_arm64.s | |
parent | bcc5c6aa502f3efda253a8e1f6680a6aab7ca966 (diff) | |
download | go-73ff7cb1ed56921c82bf6bdfc173ce8e49ea437c.tar.gz go-73ff7cb1ed56921c82bf6bdfc173ce8e49ea437c.zip |
runtime: c-shared entrypoint for linux/arm64
Change-Id: I7dab124842f5209097a8d5a802fcbdde650654fa
Reviewed-on: https://go-review.googlesource.com/16395
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/rt0_linux_arm64.s')
-rw-r--r-- | src/runtime/rt0_linux_arm64.s | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/runtime/rt0_linux_arm64.s b/src/runtime/rt0_linux_arm64.s index 1eb0352609..4027527168 100644 --- a/src/runtime/rt0_linux_arm64.s +++ b/src/runtime/rt0_linux_arm64.s @@ -9,6 +9,50 @@ TEXT _rt0_arm64_linux(SB),NOSPLIT,$-8 ADD $8, RSP, R1 // argv BL main(SB) +// When building with -buildmode=c-shared, this symbol is called when the shared +// library is loaded. +TEXT _rt0_arm64_linux_lib(SB),NOSPLIT,$40 + // 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. + MOVD R27, 24(RSP) + + MOVD R0, _rt0_arm64_linux_lib_argc<>(SB) + MOVD R1, _rt0_arm64_linux_lib_argv<>(SB) + + // Create a new thread to do the runtime initialization and return. + MOVD _cgo_sys_thread_create(SB), R4 + CMP $0, R4 + BEQ nocgo + MOVD $_rt0_arm64_linux_lib_go(SB), R0 + MOVD $0, R1 + BL (R4) + B restore + +nocgo: + MOVD $0x800000, R0 // stacksize = 8192KB + MOVD $_rt0_arm64_linux_lib_go(SB), R1 + MOVD R0, 8(RSP) + MOVD R1, 16(RSP) + MOVD $runtime·newosproc0(SB),R4 + BL (R4) + +restore: + MOVD 24(RSP), R27 + RET + +TEXT _rt0_arm64_linux_lib_go(SB),NOSPLIT,$0 + MOVD _rt0_arm64_linux_lib_argc<>(SB), R0 + MOVD _rt0_arm64_linux_lib_argv<>(SB), R1 + MOVD $runtime·rt0_go(SB),R4 + B (R4) + +DATA _rt0_arm64_linux_lib_argc<>(SB)/8, $0 +GLOBL _rt0_arm64_linux_lib_argc<>(SB),NOPTR, $8 +DATA _rt0_arm64_linux_lib_argv<>(SB)/8, $0 +GLOBL _rt0_arm64_linux_lib_argv<>(SB),NOPTR, $8 + + TEXT main(SB),NOSPLIT,$-8 MOVD $runtime·rt0_go(SB), R2 BL (R2) |