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.
6 #include "cgo/abi_arm64.h"
8 // On FreeBSD argc/argv are passed in R0, not RSP
9 TEXT _rt0_arm64_freebsd(SB),NOSPLIT|NOFRAME,$0
10 ADD $8, R0, R1 // argv
11 MOVD 0(R0), R0 // argc
14 // When building with -buildmode=c-shared, this symbol is called when the shared
16 TEXT _rt0_arm64_freebsd_lib(SB),NOSPLIT,$184
17 // Preserve callee-save registers.
21 // Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go
24 MOVD R0, _rt0_arm64_freebsd_lib_argc<>(SB)
25 MOVD R1, _rt0_arm64_freebsd_lib_argv<>(SB)
27 // Synchronous initialization.
28 MOVD $runtime·libpreinit(SB), R4
31 // Create a new thread to do the runtime initialization and return.
32 MOVD _cgo_sys_thread_create(SB), R4
34 MOVD $_rt0_arm64_freebsd_lib_go(SB), R0
36 SUB $16, RSP // reserve 16 bytes for sp-8 where fp may be saved.
42 MOVD $0x800000, R0 // stacksize = 8192KB
43 MOVD $_rt0_arm64_freebsd_lib_go(SB), R1
46 MOVD $runtime·newosproc0(SB),R4
50 // Restore callee-save registers.
51 RESTORE_R19_TO_R28(24)
52 RESTORE_F8_TO_F15(104)
55 TEXT _rt0_arm64_freebsd_lib_go(SB),NOSPLIT,$0
56 MOVD _rt0_arm64_freebsd_lib_argc<>(SB), R0
57 MOVD _rt0_arm64_freebsd_lib_argv<>(SB), R1
58 MOVD $runtime·rt0_go(SB),R4
61 DATA _rt0_arm64_freebsd_lib_argc<>(SB)/8, $0
62 GLOBL _rt0_arm64_freebsd_lib_argc<>(SB),NOPTR, $8
63 DATA _rt0_arm64_freebsd_lib_argv<>(SB)/8, $0
64 GLOBL _rt0_arm64_freebsd_lib_argv<>(SB),NOPTR, $8
67 TEXT main(SB),NOSPLIT|NOFRAME,$0
68 MOVD $runtime·rt0_go(SB), R2
72 MOVD $1, R8 // SYS_exit