Home | History | Annotate | Download | only in runtime
      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 	// Create a new thread to do the runtime initialization and return.
     27 	MOVQ	_cgo_sys_thread_create(SB), AX
     28 	TESTQ	AX, AX
     29 	JZ	nocgo
     30 	MOVQ	$_rt0_amd64_linux_lib_go(SB), DI
     31 	MOVQ	$0, SI
     32 	CALL	AX
     33 	JMP	restore
     34 
     35 nocgo:
     36 	MOVQ	$8388608, 0(SP)                    // stacksize
     37 	MOVQ	$_rt0_amd64_linux_lib_go(SB), AX
     38 	MOVQ	AX, 8(SP)                          // fn
     39 	MOVQ	$runtimenewosproc0(SB), AX
     40 	CALL	AX
     41 
     42 restore:
     43 	MOVQ	0x10(SP), BX
     44 	MOVQ	0x18(SP), BP
     45 	MOVQ	0x20(SP), R12
     46 	MOVQ	0x28(SP), R13
     47 	MOVQ	0x30(SP), R14
     48 	MOVQ	0x38(SP), R15
     49 	RET
     50 
     51 TEXT _rt0_amd64_linux_lib_go(SB),NOSPLIT,$0
     52 	MOVQ	_rt0_amd64_linux_lib_argc<>(SB), DI
     53 	MOVQ	_rt0_amd64_linux_lib_argv<>(SB), SI
     54 	MOVQ	$runtimert0_go(SB), AX
     55 	JMP	AX
     56 
     57 DATA _rt0_amd64_linux_lib_argc<>(SB)/8, $0
     58 GLOBL _rt0_amd64_linux_lib_argc<>(SB),NOPTR, $8
     59 DATA _rt0_amd64_linux_lib_argv<>(SB)/8, $0
     60 GLOBL _rt0_amd64_linux_lib_argv<>(SB),NOPTR, $8
     61 
     62 TEXT main(SB),NOSPLIT,$-8
     63 	MOVQ	$runtimert0_go(SB), AX
     64 	JMP	AX
     65