github.com/aloncn/graphics-go@v0.0.1/src/runtime/rt0_linux_arm64.s (about)

     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_linux(SB),NOSPLIT,$-8
     8  	MOVD	0(RSP), R0	// argc
     9  	ADD	$8, RSP, R1	// argv
    10  	BL	main(SB)
    11  
    12  // When building with -buildmode=c-shared, this symbol is called when the shared
    13  // library is loaded.
    14  TEXT _rt0_arm64_linux_lib(SB),NOSPLIT,$88
    15  	// Preserve callee-save registers.
    16  	MOVD R19, 24(RSP)
    17  	MOVD R20, 32(RSP)
    18  	MOVD R21, 40(RSP)
    19  	MOVD R22, 48(RSP)
    20  	MOVD R23, 56(RSP)
    21  	MOVD R24, 64(RSP)
    22  	MOVD R25, 72(RSP)
    23  	MOVD R26, 80(RSP)
    24  	MOVD R27, 88(RSP)
    25  
    26  	MOVD	R0, _rt0_arm64_linux_lib_argc<>(SB)
    27  	MOVD	R1, _rt0_arm64_linux_lib_argv<>(SB)
    28  
    29  	// Synchronous initialization.
    30  	MOVD	$runtime·libpreinit(SB), R4
    31  	BL	(R4)
    32  
    33  	// Create a new thread to do the runtime initialization and return.
    34  	MOVD	_cgo_sys_thread_create(SB), R4
    35  	CMP	$0, R4
    36  	BEQ	nocgo
    37  	MOVD	$_rt0_arm64_linux_lib_go(SB), R0
    38  	MOVD	$0, R1
    39  	BL	(R4)
    40  	B	restore
    41  
    42  nocgo:
    43  	MOVD	$0x800000, R0                     // stacksize = 8192KB
    44  	MOVD	$_rt0_arm64_linux_lib_go(SB), R1
    45  	MOVD	R0, 8(RSP)
    46  	MOVD	R1, 16(RSP)
    47  	MOVD	$runtime·newosproc0(SB),R4
    48  	BL	(R4)
    49  
    50  restore:
    51  	// Restore callee-save registers.
    52  	MOVD 24(RSP), R19
    53  	MOVD 32(RSP), R20
    54  	MOVD 40(RSP), R21
    55  	MOVD 48(RSP), R22
    56  	MOVD 56(RSP), R23
    57  	MOVD 64(RSP), R24
    58  	MOVD 72(RSP), R25
    59  	MOVD 80(RSP), R26
    60  	MOVD 88(RSP), R27
    61  	RET
    62  
    63  TEXT _rt0_arm64_linux_lib_go(SB),NOSPLIT,$0
    64  	MOVD	_rt0_arm64_linux_lib_argc<>(SB), R0
    65  	MOVD	_rt0_arm64_linux_lib_argv<>(SB), R1
    66  	MOVD	$runtime·rt0_go(SB),R4
    67  	B       (R4)
    68  
    69  DATA _rt0_arm64_linux_lib_argc<>(SB)/8, $0
    70  GLOBL _rt0_arm64_linux_lib_argc<>(SB),NOPTR, $8
    71  DATA _rt0_arm64_linux_lib_argv<>(SB)/8, $0
    72  GLOBL _rt0_arm64_linux_lib_argv<>(SB),NOPTR, $8
    73  
    74  
    75  TEXT main(SB),NOSPLIT,$-8
    76  	MOVD	$runtime·rt0_go(SB), R2
    77  	BL	(R2)
    78  exit:
    79  	MOVD $0, R0
    80  	MOVD	$94, R8	// sys_exit
    81  	SVC
    82  	B	exit