github.com/megatontech/mynoteforgo@v0.0.0-20200507084910-5d0c6ea6e890/源码/runtime/rt0_darwin_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 // No need for _rt0_arm64_darwin as darwin/arm64 only 8 // supports external linking. 9 TEXT _rt0_arm64_darwin(SB),NOSPLIT|NOFRAME,$0 10 MOVD $42, R0 11 BL libc_exit(SB) 12 13 // When linking with -buildmode=c-archive or -buildmode=c-shared, 14 // this symbol is called from a global initialization function. 15 // 16 // Note that all currently shipping darwin/arm64 platforms require 17 // cgo and do not support c-shared. 18 TEXT _rt0_arm64_darwin_lib(SB),NOSPLIT,$168 19 // Preserve callee-save registers. 20 MOVD R19, 24(RSP) 21 MOVD R20, 32(RSP) 22 MOVD R21, 40(RSP) 23 MOVD R22, 48(RSP) 24 MOVD R23, 56(RSP) 25 MOVD R24, 64(RSP) 26 MOVD R25, 72(RSP) 27 MOVD R26, 80(RSP) 28 MOVD R27, 88(RSP) 29 MOVD g, 96(RSP) 30 FMOVD F8, 104(RSP) 31 FMOVD F9, 112(RSP) 32 FMOVD F10, 120(RSP) 33 FMOVD F11, 128(RSP) 34 FMOVD F12, 136(RSP) 35 FMOVD F13, 144(RSP) 36 FMOVD F14, 152(RSP) 37 FMOVD F15, 160(RSP) 38 39 MOVD R0, _rt0_arm64_darwin_lib_argc<>(SB) 40 MOVD R1, _rt0_arm64_darwin_lib_argv<>(SB) 41 42 MOVD $0, g // initialize g to nil 43 44 // Synchronous initialization. 45 MOVD $runtime·libpreinit(SB), R4 46 BL (R4) 47 48 // Create a new thread to do the runtime initialization and return. 49 MOVD _cgo_sys_thread_create(SB), R4 50 MOVD $_rt0_arm64_darwin_lib_go(SB), R0 51 MOVD $0, R1 52 SUB $16, RSP // reserve 16 bytes for sp-8 where fp may be saved. 53 BL (R4) 54 ADD $16, RSP 55 56 // Restore callee-save registers. 57 MOVD 24(RSP), R19 58 MOVD 32(RSP), R20 59 MOVD 40(RSP), R21 60 MOVD 48(RSP), R22 61 MOVD 56(RSP), R23 62 MOVD 64(RSP), R24 63 MOVD 72(RSP), R25 64 MOVD 80(RSP), R26 65 MOVD 88(RSP), R27 66 MOVD 96(RSP), g 67 FMOVD 104(RSP), F8 68 FMOVD 112(RSP), F9 69 FMOVD 120(RSP), F10 70 FMOVD 128(RSP), F11 71 FMOVD 136(RSP), F12 72 FMOVD 144(RSP), F13 73 FMOVD 152(RSP), F14 74 FMOVD 160(RSP), F15 75 76 RET 77 78 TEXT _rt0_arm64_darwin_lib_go(SB),NOSPLIT,$0 79 MOVD _rt0_arm64_darwin_lib_argc<>(SB), R0 80 MOVD _rt0_arm64_darwin_lib_argv<>(SB), R1 81 MOVD $runtime·rt0_go(SB), R4 82 B (R4) 83 84 DATA _rt0_arm64_darwin_lib_argc<>(SB)/8, $0 85 GLOBL _rt0_arm64_darwin_lib_argc<>(SB),NOPTR, $8 86 DATA _rt0_arm64_darwin_lib_argv<>(SB)/8, $0 87 GLOBL _rt0_arm64_darwin_lib_argv<>(SB),NOPTR, $8 88 89 TEXT main(SB),NOSPLIT|NOFRAME,$0 90 MOVD $runtime·rt0_go(SB), R2 91 BL (R2) 92 exit: 93 MOVD $0, R0 94 MOVD $1, R16 // sys_exit 95 SVC $0x80 96 B exit