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

     1  // Copyright 2009 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_amd64_linux(SB),NOSPLIT,$-8
     8  	LEAQ	8(SP), SI // argv
     9  	MOVQ	0(SP), DI // argc
    10  	MOVQ	$main(SB), AX
    11  	JMP	AX
    12  
    13  // When building with -buildmode=c-shared, this symbol is called when the shared
    14  // library is loaded.
    15  TEXT _rt0_amd64_linux_lib(SB),NOSPLIT,$0x48
    16  	MOVQ	BX, 0x10(SP)
    17  	MOVQ	BP, 0x18(SP)
    18  	MOVQ	R12, 0x20(SP)
    19  	MOVQ	R13, 0x28(SP)
    20  	MOVQ	R14, 0x30(SP)
    21  	MOVQ	R15, 0x38(SP)
    22  
    23  	MOVQ	DI, _rt0_amd64_linux_lib_argc<>(SB)
    24  	MOVQ	SI, _rt0_amd64_linux_lib_argv<>(SB)
    25  
    26  	// Synchronous initialization.
    27  	MOVQ	$runtime·libpreinit(SB), AX
    28  	CALL	AX
    29  
    30  	// Create a new thread to do the runtime initialization and return.
    31  	MOVQ	_cgo_sys_thread_create(SB), AX
    32  	TESTQ	AX, AX
    33  	JZ	nocgo
    34  	MOVQ	$_rt0_amd64_linux_lib_go(SB), DI
    35  	MOVQ	$0, SI
    36  	CALL	AX
    37  	JMP	restore
    38  
    39  nocgo:
    40  	MOVQ	$8388608, 0(SP)                    // stacksize
    41  	MOVQ	$_rt0_amd64_linux_lib_go(SB), AX
    42  	MOVQ	AX, 8(SP)                          // fn
    43  	MOVQ	$runtime·newosproc0(SB), AX
    44  	CALL	AX
    45  
    46  restore:
    47  	MOVQ	0x10(SP), BX
    48  	MOVQ	0x18(SP), BP
    49  	MOVQ	0x20(SP), R12
    50  	MOVQ	0x28(SP), R13
    51  	MOVQ	0x30(SP), R14
    52  	MOVQ	0x38(SP), R15
    53  	RET
    54  
    55  TEXT _rt0_amd64_linux_lib_go(SB),NOSPLIT,$0
    56  	MOVQ	_rt0_amd64_linux_lib_argc<>(SB), DI
    57  	MOVQ	_rt0_amd64_linux_lib_argv<>(SB), SI
    58  	MOVQ	$runtime·rt0_go(SB), AX
    59  	JMP	AX
    60  
    61  DATA _rt0_amd64_linux_lib_argc<>(SB)/8, $0
    62  GLOBL _rt0_amd64_linux_lib_argc<>(SB),NOPTR, $8
    63  DATA _rt0_amd64_linux_lib_argv<>(SB)/8, $0
    64  GLOBL _rt0_amd64_linux_lib_argv<>(SB),NOPTR, $8
    65  
    66  TEXT main(SB),NOSPLIT,$-8
    67  	MOVQ	$runtime·rt0_go(SB), AX
    68  	JMP	AX