github.com/x04/go/src@v0.0.0-20200202162449-3d481ceb3525/runtime/rt0_freebsd_arm64.s (about) 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 7 // On FreeBSD argc/argv are passed in R0, not RSP 8 TEXT _rt0_arm64_freebsd(SB),NOSPLIT|NOFRAME,$0 9 ADD $8, R0, R1 // argv 10 MOVD 0(R0), R0 // argc 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_freebsd_lib(SB),NOSPLIT,$184 16 // Preserve callee-save registers. 17 MOVD R19, 24(RSP) 18 MOVD R20, 32(RSP) 19 MOVD R21, 40(RSP) 20 MOVD R22, 48(RSP) 21 MOVD R23, 56(RSP) 22 MOVD R24, 64(RSP) 23 MOVD R25, 72(RSP) 24 MOVD R26, 80(RSP) 25 MOVD R27, 88(RSP) 26 FMOVD F8, 96(RSP) 27 FMOVD F9, 104(RSP) 28 FMOVD F10, 112(RSP) 29 FMOVD F11, 120(RSP) 30 FMOVD F12, 128(RSP) 31 FMOVD F13, 136(RSP) 32 FMOVD F14, 144(RSP) 33 FMOVD F15, 152(RSP) 34 MOVD g, 160(RSP) 35 36 // Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go 37 MOVD ZR, g 38 39 MOVD R0, _rt0_arm64_freebsd_lib_argc<>(SB) 40 MOVD R1, _rt0_arm64_freebsd_lib_argv<>(SB) 41 42 // Synchronous initialization. 43 MOVD $runtime·libpreinit(SB), R4 44 BL (R4) 45 46 // Create a new thread to do the runtime initialization and return. 47 MOVD _cgo_sys_thread_create(SB), R4 48 CMP $0, R4 49 BEQ nocgo 50 MOVD $_rt0_arm64_freebsd_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 B restore 56 57 nocgo: 58 MOVD $0x800000, R0 // stacksize = 8192KB 59 MOVD $_rt0_arm64_freebsd_lib_go(SB), R1 60 MOVD R0, 8(RSP) 61 MOVD R1, 16(RSP) 62 MOVD $runtime·newosproc0(SB),R4 63 BL (R4) 64 65 restore: 66 // Restore callee-save registers. 67 MOVD 24(RSP), R19 68 MOVD 32(RSP), R20 69 MOVD 40(RSP), R21 70 MOVD 48(RSP), R22 71 MOVD 56(RSP), R23 72 MOVD 64(RSP), R24 73 MOVD 72(RSP), R25 74 MOVD 80(RSP), R26 75 MOVD 88(RSP), R27 76 FMOVD 96(RSP), F8 77 FMOVD 104(RSP), F9 78 FMOVD 112(RSP), F10 79 FMOVD 120(RSP), F11 80 FMOVD 128(RSP), F12 81 FMOVD 136(RSP), F13 82 FMOVD 144(RSP), F14 83 FMOVD 152(RSP), F15 84 MOVD 160(RSP), g 85 RET 86 87 TEXT _rt0_arm64_freebsd_lib_go(SB),NOSPLIT,$0 88 MOVD _rt0_arm64_freebsd_lib_argc<>(SB), R0 89 MOVD _rt0_arm64_freebsd_lib_argv<>(SB), R1 90 MOVD $runtime·rt0_go(SB),R4 91 B (R4) 92 93 DATA _rt0_arm64_freebsd_lib_argc<>(SB)/8, $0 94 GLOBL _rt0_arm64_freebsd_lib_argc<>(SB),NOPTR, $8 95 DATA _rt0_arm64_freebsd_lib_argv<>(SB)/8, $0 96 GLOBL _rt0_arm64_freebsd_lib_argv<>(SB),NOPTR, $8 97 98 99 TEXT main(SB),NOSPLIT|NOFRAME,$0 100 MOVD $runtime·rt0_go(SB), R2 101 BL (R2) 102 exit: 103 MOVD $0, R0 104 MOVD $1, R8 // SYS_exit 105 SVC 106 B exit