github.com/mdempsky/go@v0.0.0-20151201204031-5dd372bd1e70/src/runtime/rt0_linux_arm64.s (about) 1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include "textflag.h" 6 7 TEXT _rt0_arm64_linux(SB),NOSPLIT,$-8 8 MOVD 0(RSP), R0 // argc 9 ADD $8, RSP, R1 // argv 10 BL main(SB) 11 12 // When building with -buildmode=c-shared, this symbol is called when the shared 13 // library is loaded. 14 TEXT _rt0_arm64_linux_lib(SB),NOSPLIT,$40 15 // R27 is REGTMP, reserved for liblink. It is used below to 16 // move R0/R1 into globals. However in the standard ARM64 calling 17 // convention, it is a callee-saved register. 18 MOVD R27, 24(RSP) 19 20 MOVD R0, _rt0_arm64_linux_lib_argc<>(SB) 21 MOVD R1, _rt0_arm64_linux_lib_argv<>(SB) 22 23 // Create a new thread to do the runtime initialization and return. 24 MOVD _cgo_sys_thread_create(SB), R4 25 CMP $0, R4 26 BEQ nocgo 27 MOVD $_rt0_arm64_linux_lib_go(SB), R0 28 MOVD $0, R1 29 BL (R4) 30 B restore 31 32 nocgo: 33 MOVD $0x800000, R0 // stacksize = 8192KB 34 MOVD $_rt0_arm64_linux_lib_go(SB), R1 35 MOVD R0, 8(RSP) 36 MOVD R1, 16(RSP) 37 MOVD $runtime·newosproc0(SB),R4 38 BL (R4) 39 40 restore: 41 MOVD 24(RSP), R27 42 RET 43 44 TEXT _rt0_arm64_linux_lib_go(SB),NOSPLIT,$0 45 MOVD _rt0_arm64_linux_lib_argc<>(SB), R0 46 MOVD _rt0_arm64_linux_lib_argv<>(SB), R1 47 MOVD $runtime·rt0_go(SB),R4 48 B (R4) 49 50 DATA _rt0_arm64_linux_lib_argc<>(SB)/8, $0 51 GLOBL _rt0_arm64_linux_lib_argc<>(SB),NOPTR, $8 52 DATA _rt0_arm64_linux_lib_argv<>(SB)/8, $0 53 GLOBL _rt0_arm64_linux_lib_argv<>(SB),NOPTR, $8 54 55 56 TEXT main(SB),NOSPLIT,$-8 57 MOVD $runtime·rt0_go(SB), R2 58 BL (R2) 59 exit: 60 MOVD $0, R0 61 MOVD $94, R8 // sys_exit 62 SVC 63 B exit