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,$-8 10 MOVD $42, R0 11 MOVD $1, R16 // SYS_exit 12 SVC $0x80 13 14 // When linking with -buildmode=c-archive or -buildmode=c-shared, 15 // this symbol is called from a global initialization function. 16 // 17 // Note that all currently shipping darwin/arm64 platforms require 18 // cgo and do not support c-shared. 19 TEXT _rt0_arm64_darwin_lib(SB),NOSPLIT,$0 20 // R27 is REGTMP, reserved for liblink. It is used below to 21 // move R0/R1 into globals. However in the standard ARM64 calling 22 // convention, it is a callee-saved register. So we save it to a 23 // temporary register. 24 MOVD R27, R7 25 26 MOVD R0, _rt0_arm64_darwin_lib_argc<>(SB) 27 MOVD R1, _rt0_arm64_darwin_lib_argv<>(SB) 28 // Create a new thread to do the runtime initialization and return. 29 MOVD _cgo_sys_thread_create(SB), R4 30 MOVD $_rt0_arm64_darwin_lib_go(SB), R0 31 MOVD $0, R1 32 BL (R4) 33 34 MOVD R7, R27 35 RET 36 37 TEXT _rt0_arm64_darwin_lib_go(SB),NOSPLIT,$0 38 MOVD _rt0_arm64_darwin_lib_argc<>(SB), R0 39 MOVD _rt0_arm64_darwin_lib_argv<>(SB), R1 40 MOVD $runtimert0_go(SB), R4 41 B (R4) 42 43 DATA _rt0_arm64_darwin_lib_argc<>(SB)/8, $0 44 GLOBL _rt0_arm64_darwin_lib_argc<>(SB),NOPTR, $8 45 DATA _rt0_arm64_darwin_lib_argv<>(SB)/8, $0 46 GLOBL _rt0_arm64_darwin_lib_argv<>(SB),NOPTR, $8 47 48 TEXT main(SB),NOSPLIT,$-8 49 MOVD $runtimert0_go(SB), R2 50 BL (R2) 51 exit: 52 MOVD $0, R0 53 MOVD $1, R16 // sys_exit 54 SVC $0x80 55 B exit 56