...
Run Format

Text file src/runtime/rt0_darwin_amd64.s

Documentation: 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_darwin(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 linking with -shared, this symbol is called when the shared library
    14	// is loaded.
    15	TEXT _rt0_amd64_darwin_lib(SB),NOSPLIT,$0x58
    16		// Align stack. We don't know whether Go is adding a frame pointer here or not.
    17		MOVQ	SP, R8
    18		SUBQ	$16, R8
    19		ANDQ	$~15, R8
    20		XCHGQ	SP, R8
    21	
    22		MOVQ	R8, 0x48(SP)
    23		MOVQ	BX, 0x18(SP)
    24		MOVQ	BP, 0x20(SP)
    25		MOVQ	R12, 0x28(SP)
    26		MOVQ	R13, 0x30(SP)
    27		MOVQ	R14, 0x38(SP)
    28		MOVQ	R15, 0x40(SP)
    29	
    30		MOVQ	DI, _rt0_amd64_darwin_lib_argc<>(SB)
    31		MOVQ	SI, _rt0_amd64_darwin_lib_argv<>(SB)
    32	
    33		// Synchronous initialization.
    34		MOVQ	$runtime·libpreinit(SB), AX
    35		CALL	AX
    36	
    37		// Create a new thread to do the runtime initialization and return.
    38		MOVQ	_cgo_sys_thread_create(SB), AX
    39		TESTQ	AX, AX
    40		JZ	nocgo
    41		MOVQ	$_rt0_amd64_darwin_lib_go(SB), DI
    42		MOVQ	$0, SI
    43		CALL	AX
    44		JMP	restore
    45	
    46	nocgo:
    47		MOVQ	$8388608, 0(SP)                    // stacksize
    48		MOVQ	$_rt0_amd64_darwin_lib_go(SB), AX
    49		MOVQ	AX, 8(SP)                          // fn
    50		MOVQ	$0, 16(SP)                         // fnarg
    51		MOVQ	$runtime·newosproc0(SB), AX
    52		CALL	AX
    53	
    54	restore:
    55		MOVQ	0x18(SP), BX
    56		MOVQ	0x20(SP), BP
    57		MOVQ	0x28(SP), R12
    58		MOVQ	0x30(SP), R13
    59		MOVQ	0x38(SP), R14
    60		MOVQ	0x40(SP), R15
    61		
    62		MOVQ	0x48(SP), R8
    63		MOVQ	R8, SP
    64		RET
    65	
    66	TEXT _rt0_amd64_darwin_lib_go(SB),NOSPLIT,$0
    67		MOVQ	_rt0_amd64_darwin_lib_argc<>(SB), DI
    68		MOVQ	_rt0_amd64_darwin_lib_argv<>(SB), SI
    69		MOVQ	$runtime·rt0_go(SB), AX
    70		JMP	AX
    71	
    72	DATA _rt0_amd64_darwin_lib_argc<>(SB)/8, $0
    73	GLOBL _rt0_amd64_darwin_lib_argc<>(SB),NOPTR, $8
    74	DATA _rt0_amd64_darwin_lib_argv<>(SB)/8, $0
    75	GLOBL _rt0_amd64_darwin_lib_argv<>(SB),NOPTR, $8
    76	
    77	TEXT main(SB),NOSPLIT,$-8
    78		MOVQ	$runtime·rt0_go(SB), AX
    79		JMP	AX

View as plain text