Text file
src/runtime/rt0_darwin_arm64.s
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 #include "cgo/abi_arm64.h"
7
8 TEXT _rt0_arm64_darwin(SB),NOSPLIT|NOFRAME,$0
9 MOVD $runtime·rt0_go(SB), R2
10 BL (R2)
11 exit:
12 MOVD $0, R0
13 MOVD $1, R16 // sys_exit
14 SVC $0x80
15 B exit
16
17 // When linking with -buildmode=c-archive or -buildmode=c-shared,
18 // this symbol is called from a global initialization function.
19 //
20 // Note that all currently shipping darwin/arm64 platforms require
21 // cgo and do not support c-shared.
22 TEXT _rt0_arm64_darwin_lib(SB),NOSPLIT,$152
23 // Preserve callee-save registers.
24 SAVE_R19_TO_R28(8)
25 SAVE_F8_TO_F15(88)
26
27 MOVD R0, _rt0_arm64_darwin_lib_argc<>(SB)
28 MOVD R1, _rt0_arm64_darwin_lib_argv<>(SB)
29
30 MOVD $0, g // initialize g to nil
31
32 // Synchronous initialization.
33 MOVD $runtime·libpreinit(SB), R4
34 BL (R4)
35
36 // Create a new thread to do the runtime initialization and return.
37 MOVD _cgo_sys_thread_create(SB), R4
38 MOVD $_rt0_arm64_darwin_lib_go(SB), R0
39 MOVD $0, R1
40 SUB $16, RSP // reserve 16 bytes for sp-8 where fp may be saved.
41 BL (R4)
42 ADD $16, RSP
43
44 // Restore callee-save registers.
45 RESTORE_R19_TO_R28(8)
46 RESTORE_F8_TO_F15(88)
47
48 RET
49
50 TEXT _rt0_arm64_darwin_lib_go(SB),NOSPLIT,$0
51 MOVD _rt0_arm64_darwin_lib_argc<>(SB), R0
52 MOVD _rt0_arm64_darwin_lib_argv<>(SB), R1
53 MOVD $runtime·rt0_go(SB), R4
54 B (R4)
55
56 DATA _rt0_arm64_darwin_lib_argc<>(SB)/8, $0
57 GLOBL _rt0_arm64_darwin_lib_argc<>(SB),NOPTR, $8
58 DATA _rt0_arm64_darwin_lib_argv<>(SB)/8, $0
59 GLOBL _rt0_arm64_darwin_lib_argv<>(SB),NOPTR, $8
60
61 // external linking entry point.
62 TEXT main(SB),NOSPLIT|NOFRAME,$0
63 JMP _rt0_arm64_darwin(SB)
64
View as plain text