...
Run Format

Text file src/runtime/rt0_linux_386.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_386_linux(SB),NOSPLIT,$8
     8		MOVL	8(SP), AX
     9		LEAL	12(SP), BX
    10		MOVL	AX, 0(SP)
    11		MOVL	BX, 4(SP)
    12		CALL	main(SB)
    13		INT	$3
    14	
    15	// When building with -buildmode=c-shared, this symbol is called when the shared
    16	// library is loaded.
    17	TEXT _rt0_386_linux_lib(SB),NOSPLIT,$0
    18		PUSHL	BP
    19		MOVL	SP, BP
    20		PUSHL	BX
    21		PUSHL	SI
    22		PUSHL	DI
    23	
    24		MOVL	8(BP), AX
    25		MOVL	AX, _rt0_386_linux_lib_argc<>(SB)
    26		MOVL	12(BP), AX
    27		MOVL	AX, _rt0_386_linux_lib_argv<>(SB)
    28	
    29		// Synchronous initialization.
    30		MOVL	$runtime·libpreinit(SB), AX
    31		CALL	AX
    32	
    33		SUBL	$8, SP
    34	
    35		// Create a new thread to do the runtime initialization.
    36		MOVL	_cgo_sys_thread_create(SB), AX
    37		TESTL	AX, AX
    38		JZ	nocgo
    39		MOVL	$_rt0_386_linux_lib_go(SB), BX
    40		MOVL	BX, 0(SP)
    41		MOVL	$0, 4(SP)
    42		CALL	AX
    43		JMP	restore
    44	
    45	nocgo:
    46		MOVL	$0x800000, 0(SP)                    // stacksize = 8192KB
    47		MOVL	$_rt0_386_linux_lib_go(SB), AX
    48		MOVL	AX, 4(SP)                           // fn
    49		MOVL	$runtime·newosproc0(SB), AX
    50		CALL	AX
    51	
    52	restore:
    53		ADDL	$8, SP
    54		POPL	DI
    55		POPL	SI
    56		POPL	BX
    57		POPL	BP
    58		RET
    59	
    60	TEXT _rt0_386_linux_lib_go(SB),NOSPLIT,$12
    61		MOVL	_rt0_386_linux_lib_argc<>(SB), AX
    62		MOVL	AX, 0(SP)
    63		MOVL	_rt0_386_linux_lib_argv<>(SB), AX
    64		MOVL	AX, 4(SP)
    65		MOVL	$runtime·rt0_go(SB), AX
    66		CALL	AX
    67		RET
    68	
    69	DATA _rt0_386_linux_lib_argc<>(SB)/4, $0
    70	GLOBL _rt0_386_linux_lib_argc<>(SB),NOPTR, $4
    71	DATA _rt0_386_linux_lib_argv<>(SB)/4, $0
    72	GLOBL _rt0_386_linux_lib_argv<>(SB),NOPTR, $4
    73	
    74	TEXT main(SB),NOSPLIT,$0
    75		JMP	runtime·rt0_go(SB)

View as plain text