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,$168 15 // Preserve callee-save registers. 16 MOVD R19, 24(RSP) 17 MOVD R20, 32(RSP) 18 MOVD R21, 40(RSP) 19 MOVD R22, 48(RSP) 20 MOVD R23, 56(RSP) 21 MOVD R24, 64(RSP) 22 MOVD R25, 72(RSP) 23 MOVD R26, 80(RSP) 24 MOVD R27, 88(RSP) 25 FMOVD F8, 96(RSP) 26 FMOVD F9, 104(RSP) 27 FMOVD F10, 112(RSP) 28 FMOVD F11, 120(RSP) 29 FMOVD F12, 128(RSP) 30 FMOVD F13, 136(RSP) 31 FMOVD F14, 144(RSP) 32 FMOVD F15, 152(RSP) 33 34 MOVD R0, _rt0_arm64_linux_lib_argc<>(SB) 35 MOVD R1, _rt0_arm64_linux_lib_argv<>(SB) 36 37 // Synchronous initialization. 38 MOVD $runtimelibpreinit(SB), R4 39 BL (R4) 40 41 // Create a new thread to do the runtime initialization and return. 42 MOVD _cgo_sys_thread_create(SB), R4 43 CMP $0, R4 44 BEQ nocgo 45 MOVD $_rt0_arm64_linux_lib_go(SB), R0 46 MOVD $0, R1 47 BL (R4) 48 B restore 49 50 nocgo: 51 MOVD $0x800000, R0 // stacksize = 8192KB 52 MOVD $_rt0_arm64_linux_lib_go(SB), R1 53 MOVD R0, 8(RSP) 54 MOVD R1, 16(RSP) 55 MOVD $runtimenewosproc0(SB),R4 56 BL (R4) 57 58 restore: 59 // Restore callee-save registers. 60 MOVD 24(RSP), R19 61 MOVD 32(RSP), R20 62 MOVD 40(RSP), R21 63 MOVD 48(RSP), R22 64 MOVD 56(RSP), R23 65 MOVD 64(RSP), R24 66 MOVD 72(RSP), R25 67 MOVD 80(RSP), R26 68 MOVD 88(RSP), R27 69 FMOVD 96(RSP), F8 70 FMOVD 104(RSP), F9 71 FMOVD 112(RSP), F10 72 FMOVD 120(RSP), F11 73 FMOVD 128(RSP), F12 74 FMOVD 136(RSP), F13 75 FMOVD 144(RSP), F14 76 FMOVD 152(RSP), F15 77 RET 78 79 TEXT _rt0_arm64_linux_lib_go(SB),NOSPLIT,$0 80 MOVD _rt0_arm64_linux_lib_argc<>(SB), R0 81 MOVD _rt0_arm64_linux_lib_argv<>(SB), R1 82 MOVD $runtimert0_go(SB),R4 83 B (R4) 84 85 DATA _rt0_arm64_linux_lib_argc<>(SB)/8, $0 86 GLOBL _rt0_arm64_linux_lib_argc<>(SB),NOPTR, $8 87 DATA _rt0_arm64_linux_lib_argv<>(SB)/8, $0 88 GLOBL _rt0_arm64_linux_lib_argv<>(SB),NOPTR, $8 89 90 91 TEXT main(SB),NOSPLIT,$-8 92 MOVD $runtimert0_go(SB), R2 93 BL (R2) 94 exit: 95 MOVD $0, R0 96 MOVD $94, R8 // sys_exit 97 SVC 98 B exit 99