...
Run Format

Text file src/runtime/rt0_darwin_arm64.s

Documentation: runtime

     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|NOFRAME,$0
    10		MOVD	$42, R0
    11		BL  libc_exit(SB)
    12	
    13	// When linking with -buildmode=c-archive or -buildmode=c-shared,
    14	// this symbol is called from a global initialization function.
    15	//
    16	// Note that all currently shipping darwin/arm64 platforms require
    17	// cgo and do not support c-shared.
    18	TEXT _rt0_arm64_darwin_lib(SB),NOSPLIT,$168
    19		// Preserve callee-save registers.
    20		MOVD R19, 24(RSP)
    21		MOVD R20, 32(RSP)
    22		MOVD R21, 40(RSP)
    23		MOVD R22, 48(RSP)
    24		MOVD R23, 56(RSP)
    25		MOVD R24, 64(RSP)
    26		MOVD R25, 72(RSP)
    27		MOVD R26, 80(RSP)
    28		MOVD R27, 88(RSP)
    29		MOVD g, 96(RSP)
    30		FMOVD F8, 104(RSP)
    31		FMOVD F9, 112(RSP)
    32		FMOVD F10, 120(RSP)
    33		FMOVD F11, 128(RSP)
    34		FMOVD F12, 136(RSP)
    35		FMOVD F13, 144(RSP)
    36		FMOVD F14, 152(RSP)
    37		FMOVD F15, 160(RSP)
    38	
    39		MOVD  R0, _rt0_arm64_darwin_lib_argc<>(SB)
    40		MOVD  R1, _rt0_arm64_darwin_lib_argv<>(SB)
    41	
    42		MOVD	$0, g // initialize g to nil
    43	
    44		// Synchronous initialization.
    45		MOVD	$runtime·libpreinit(SB), R4
    46		BL	(R4)
    47	
    48		// Create a new thread to do the runtime initialization and return.
    49		MOVD  _cgo_sys_thread_create(SB), R4
    50		MOVD  $_rt0_arm64_darwin_lib_go(SB), R0
    51		MOVD  $0, R1
    52		BL    (R4)
    53	
    54		// Restore callee-save registers.
    55		MOVD 24(RSP), R19
    56		MOVD 32(RSP), R20
    57		MOVD 40(RSP), R21
    58		MOVD 48(RSP), R22
    59		MOVD 56(RSP), R23
    60		MOVD 64(RSP), R24
    61		MOVD 72(RSP), R25
    62		MOVD 80(RSP), R26
    63		MOVD 88(RSP), R27
    64		MOVD 96(RSP), g
    65		FMOVD 104(RSP), F8
    66		FMOVD 112(RSP), F9
    67		FMOVD 120(RSP), F10
    68		FMOVD 128(RSP), F11
    69		FMOVD 136(RSP), F12
    70		FMOVD 144(RSP), F13
    71		FMOVD 152(RSP), F14
    72		FMOVD 160(RSP), F15
    73	
    74		RET
    75	
    76	TEXT _rt0_arm64_darwin_lib_go(SB),NOSPLIT,$0
    77		MOVD  _rt0_arm64_darwin_lib_argc<>(SB), R0
    78		MOVD  _rt0_arm64_darwin_lib_argv<>(SB), R1
    79		MOVD  $runtime·rt0_go(SB), R4
    80		B     (R4)
    81	
    82	DATA  _rt0_arm64_darwin_lib_argc<>(SB)/8, $0
    83	GLOBL _rt0_arm64_darwin_lib_argc<>(SB),NOPTR, $8
    84	DATA  _rt0_arm64_darwin_lib_argv<>(SB)/8, $0
    85	GLOBL _rt0_arm64_darwin_lib_argv<>(SB),NOPTR, $8
    86	
    87	TEXT main(SB),NOSPLIT|NOFRAME,$0
    88		MOVD	$runtime·rt0_go(SB), R2
    89		BL	(R2)
    90	exit:
    91		MOVD	$0, R0
    92		MOVD	$1, R16	// sys_exit
    93		SVC	$0x80
    94		B	exit

View as plain text