...
Run Format

Text file src/runtime/rt0_darwin_arm.s

Documentation: runtime

     1	// Copyright 2014 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_arm_darwin(SB),7,$-4
     8		// prepare arguments for main (_rt0_go)
     9		MOVW	(R13), R0	// argc
    10		MOVW	$4(R13), R1		// argv
    11		MOVW	$main(SB), R4
    12		B		(R4)
    13	
    14	// When linking with -buildmode=c-archive or -buildmode=c-shared,
    15	// this symbol is called from a global initialization function.
    16	//
    17	// Note that all currently shipping darwin/arm platforms require
    18	// cgo and do not support c-shared.
    19	TEXT _rt0_arm_darwin_lib(SB),NOSPLIT,$104
    20		// Preserve callee-save registers.
    21		MOVW    R4, 12(R13)
    22		MOVW    R5, 16(R13)
    23		MOVW    R6, 20(R13)
    24		MOVW    R7, 24(R13)
    25		MOVW    R8, 28(R13)
    26		MOVW    R11, 32(R13)
    27	
    28		MOVD	F8, (32+8*1)(R13)
    29		MOVD	F9, (32+8*2)(R13)
    30		MOVD	F10, (32+8*3)(R13)
    31		MOVD	F11, (32+8*4)(R13)
    32		MOVD	F12, (32+8*5)(R13)
    33		MOVD	F13, (32+8*6)(R13)
    34		MOVD	F14, (32+8*7)(R13)
    35		MOVD	F15, (32+8*8)(R13)
    36	
    37		MOVW  R0, _rt0_arm_darwin_lib_argc<>(SB)
    38		MOVW  R1, _rt0_arm_darwin_lib_argv<>(SB)
    39	
    40		// Synchronous initialization.
    41		MOVW	$runtime·libpreinit(SB), R3
    42		CALL	(R3)
    43	
    44		// Create a new thread to do the runtime initialization and return.
    45		MOVW  _cgo_sys_thread_create(SB), R3
    46		CMP   $0, R3
    47		B.EQ  nocgo
    48		MOVW  $_rt0_arm_darwin_lib_go(SB), R0
    49		MOVW  $0, R1
    50		BL    (R3)
    51		B rr
    52	nocgo:
    53		MOVW  $0x400000, R0
    54		MOVW  R0, (R13) // stacksize
    55		MOVW  $_rt0_arm_darwin_lib_go(SB), R0
    56		MOVW  R0, 4(R13) // fn
    57		MOVW  $0, R0
    58		MOVW  R0, 8(R13) // fnarg
    59		MOVW  $runtime·newosproc0(SB), R3
    60		BL    (R3)
    61	rr:
    62		// Restore callee-save registers and return.
    63		MOVW    12(R13), R4
    64		MOVW    16(R13), R5
    65		MOVW    20(R13), R6
    66		MOVW    24(R13), R7
    67		MOVW    28(R13), R8
    68		MOVW    32(R13), R11
    69		MOVD	(32+8*1)(R13), F8
    70		MOVD	(32+8*2)(R13), F9
    71		MOVD	(32+8*3)(R13), F10
    72		MOVD	(32+8*4)(R13), F11
    73		MOVD	(32+8*5)(R13), F12
    74		MOVD	(32+8*6)(R13), F13
    75		MOVD	(32+8*7)(R13), F14
    76		MOVD	(32+8*8)(R13), F15
    77		RET
    78	
    79	
    80	TEXT _rt0_arm_darwin_lib_go(SB),NOSPLIT,$0
    81		MOVW  _rt0_arm_darwin_lib_argc<>(SB), R0
    82		MOVW  _rt0_arm_darwin_lib_argv<>(SB), R1
    83		MOVW  R0,  (R13)
    84		MOVW  R1, 4(R13)
    85		MOVW  $runtime·rt0_go(SB), R4
    86		B     (R4)
    87	
    88	DATA  _rt0_arm_darwin_lib_argc<>(SB)/4, $0
    89	GLOBL _rt0_arm_darwin_lib_argc<>(SB),NOPTR, $4
    90	DATA  _rt0_arm_darwin_lib_argv<>(SB)/4, $0
    91	GLOBL _rt0_arm_darwin_lib_argv<>(SB),NOPTR, $4
    92	
    93	TEXT main(SB),NOSPLIT,$-8
    94		// save argc and argv onto stack
    95		MOVM.DB.W [R0-R1], (R13)
    96		MOVW	$runtime·rt0_go(SB), R4
    97		B		(R4)

View as plain text