Text file src/runtime/rt0_linux_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_linux(SB),NOSPLIT|NOFRAME,$0
     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,$184
    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  	FMOVD F8, 96(RSP)
    26  	FMOVD F9, 104(RSP)
    27  	FMOVD F10, 112(RSP)
    28  	FMOVD F11, 120(RSP)
    29  	FMOVD F12, 128(RSP)
    30  	FMOVD F13, 136(RSP)
    31  	FMOVD F14, 144(RSP)
    32  	FMOVD F15, 152(RSP)
    33  	MOVD g, 160(RSP)
    34  
    35  	// Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go
    36  	MOVD	ZR, g
    37  
    38  	MOVD	R0, _rt0_arm64_linux_lib_argc<>(SB)
    39  	MOVD	R1, _rt0_arm64_linux_lib_argv<>(SB)
    40  
    41  	// Synchronous initialization.
    42  	MOVD	$runtime·libpreinit(SB), R4
    43  	BL	(R4)
    44  
    45  	// Create a new thread to do the runtime initialization and return.
    46  	MOVD	_cgo_sys_thread_create(SB), R4
    47  	CBZ	R4, nocgo
    48  	MOVD	$_rt0_arm64_linux_lib_go(SB), R0
    49  	MOVD	$0, R1
    50  	SUB	$16, RSP		// reserve 16 bytes for sp-8 where fp may be saved.
    51  	BL	(R4)
    52  	ADD	$16, RSP
    53  	B	restore
    54  
    55  nocgo:
    56  	MOVD	$0x800000, R0                     // stacksize = 8192KB
    57  	MOVD	$_rt0_arm64_linux_lib_go(SB), R1
    58  	MOVD	R0, 8(RSP)
    59  	MOVD	R1, 16(RSP)
    60  	MOVD	$runtime·newosproc0(SB),R4
    61  	BL	(R4)
    62  
    63  restore:
    64  	// Restore callee-save registers.
    65  	MOVD 24(RSP), R19
    66  	MOVD 32(RSP), R20
    67  	MOVD 40(RSP), R21
    68  	MOVD 48(RSP), R22
    69  	MOVD 56(RSP), R23
    70  	MOVD 64(RSP), R24
    71  	MOVD 72(RSP), R25
    72  	MOVD 80(RSP), R26
    73  	MOVD 88(RSP), R27
    74  	FMOVD 96(RSP), F8
    75  	FMOVD 104(RSP), F9
    76  	FMOVD 112(RSP), F10
    77  	FMOVD 120(RSP), F11
    78  	FMOVD 128(RSP), F12
    79  	FMOVD 136(RSP), F13
    80  	FMOVD 144(RSP), F14
    81  	FMOVD 152(RSP), F15
    82  	MOVD 160(RSP), g
    83  	RET
    84  
    85  TEXT _rt0_arm64_linux_lib_go(SB),NOSPLIT,$0
    86  	MOVD	_rt0_arm64_linux_lib_argc<>(SB), R0
    87  	MOVD	_rt0_arm64_linux_lib_argv<>(SB), R1
    88  	MOVD	$runtime·rt0_go(SB),R4
    89  	B       (R4)
    90  
    91  DATA _rt0_arm64_linux_lib_argc<>(SB)/8, $0
    92  GLOBL _rt0_arm64_linux_lib_argc<>(SB),NOPTR, $8
    93  DATA _rt0_arm64_linux_lib_argv<>(SB)/8, $0
    94  GLOBL _rt0_arm64_linux_lib_argv<>(SB),NOPTR, $8
    95  
    96  
    97  TEXT main(SB),NOSPLIT|NOFRAME,$0
    98  	MOVD	$runtime·rt0_go(SB), R2
    99  	BL	(R2)
   100  exit:
   101  	MOVD $0, R0
   102  	MOVD	$94, R8	// sys_exit
   103  	SVC
   104  	B	exit
   105  

View as plain text