Text file src/runtime/rt0_darwin_arm64.s

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

View as plain text