Text file
src/runtime/rt0_netbsd_arm64.s
1 // Copyright 2019 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_netbsd(SB),NOSPLIT|NOFRAME,$0
9 MOVD 0(RSP), R0 // argc
10 ADD $8, RSP, R1 // argv
11 BL main(SB)
12
13 // When building with -buildmode=c-shared, this symbol is called when the shared
14 // library is loaded.
15 TEXT _rt0_arm64_netbsd_lib(SB),NOSPLIT,$184
16 // Preserve callee-save registers.
17 SAVE_R19_TO_R28(24)
18 SAVE_F8_TO_F15(104)
19
20 // Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go
21 MOVD ZR, g
22
23 MOVD R0, _rt0_arm64_netbsd_lib_argc<>(SB)
24 MOVD R1, _rt0_arm64_netbsd_lib_argv<>(SB)
25
26 // Synchronous initialization.
27 MOVD $runtime·libpreinit(SB), R4
28 BL (R4)
29
30 // Create a new thread to do the runtime initialization and return.
31 MOVD _cgo_sys_thread_create(SB), R4
32 CBZ R4, nocgo
33 MOVD $_rt0_arm64_netbsd_lib_go(SB), R0
34 MOVD $0, R1
35 SUB $16, RSP // reserve 16 bytes for sp-8 where fp may be saved.
36 BL (R4)
37 ADD $16, RSP
38 B restore
39
40 nocgo:
41 MOVD $0x800000, R0 // stacksize = 8192KB
42 MOVD $_rt0_arm64_netbsd_lib_go(SB), R1
43 MOVD R0, 8(RSP)
44 MOVD R1, 16(RSP)
45 MOVD $runtime·newosproc0(SB),R4
46 BL (R4)
47
48 restore:
49 // Restore callee-save registers.
50 RESTORE_R19_TO_R28(24)
51 RESTORE_F8_TO_F15(104)
52 RET
53
54 TEXT _rt0_arm64_netbsd_lib_go(SB),NOSPLIT,$0
55 MOVD _rt0_arm64_netbsd_lib_argc<>(SB), R0
56 MOVD _rt0_arm64_netbsd_lib_argv<>(SB), R1
57 MOVD $runtime·rt0_go(SB),R4
58 B (R4)
59
60 DATA _rt0_arm64_netbsd_lib_argc<>(SB)/8, $0
61 GLOBL _rt0_arm64_netbsd_lib_argc<>(SB),NOPTR, $8
62 DATA _rt0_arm64_netbsd_lib_argv<>(SB)/8, $0
63 GLOBL _rt0_arm64_netbsd_lib_argv<>(SB),NOPTR, $8
64
65
66 TEXT main(SB),NOSPLIT|NOFRAME,$0
67 MOVD $runtime·rt0_go(SB), R2
68 BL (R2)
69 exit:
70 MOVD $0, R0
71 SVC $1 // sys_exit
72
View as plain text