...
Run Format

Text file src/runtime/rt0_linux_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	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		CMP	$0, R4
    48		BEQ	nocgo
    49		MOVD	$_rt0_arm64_linux_lib_go(SB), R0
    50		MOVD	$0, R1
    51		BL	(R4)
    52		B	restore
    53	
    54	nocgo:
    55		MOVD	$0x800000, R0                     // stacksize = 8192KB
    56		MOVD	$_rt0_arm64_linux_lib_go(SB), R1
    57		MOVD	R0, 8(RSP)
    58		MOVD	R1, 16(RSP)
    59		MOVD	$runtime·newosproc0(SB),R4
    60		BL	(R4)
    61	
    62	restore:
    63		// Restore callee-save registers.
    64		MOVD 24(RSP), R19
    65		MOVD 32(RSP), R20
    66		MOVD 40(RSP), R21
    67		MOVD 48(RSP), R22
    68		MOVD 56(RSP), R23
    69		MOVD 64(RSP), R24
    70		MOVD 72(RSP), R25
    71		MOVD 80(RSP), R26
    72		MOVD 88(RSP), R27
    73		FMOVD 96(RSP), F8
    74		FMOVD 104(RSP), F9
    75		FMOVD 112(RSP), F10
    76		FMOVD 120(RSP), F11
    77		FMOVD 128(RSP), F12
    78		FMOVD 136(RSP), F13
    79		FMOVD 144(RSP), F14
    80		FMOVD 152(RSP), F15
    81		MOVD 160(RSP), g
    82		RET
    83	
    84	TEXT _rt0_arm64_linux_lib_go(SB),NOSPLIT,$0
    85		MOVD	_rt0_arm64_linux_lib_argc<>(SB), R0
    86		MOVD	_rt0_arm64_linux_lib_argv<>(SB), R1
    87		MOVD	$runtime·rt0_go(SB),R4
    88		B       (R4)
    89	
    90	DATA _rt0_arm64_linux_lib_argc<>(SB)/8, $0
    91	GLOBL _rt0_arm64_linux_lib_argc<>(SB),NOPTR, $8
    92	DATA _rt0_arm64_linux_lib_argv<>(SB)/8, $0
    93	GLOBL _rt0_arm64_linux_lib_argv<>(SB),NOPTR, $8
    94	
    95	
    96	TEXT main(SB),NOSPLIT|NOFRAME,$0
    97		MOVD	$runtime·rt0_go(SB), R2
    98		BL	(R2)
    99	exit:
   100		MOVD $0, R0
   101		MOVD	$94, R8	// sys_exit
   102		SVC
   103		B	exit

View as plain text