...
Run Format

Text file src/runtime/rt0_linux_ppc64le.s

Documentation: runtime

     1	#include "go_asm.h"
     2	#include "textflag.h"
     3	
     4	TEXT _rt0_ppc64le_linux(SB),NOSPLIT,$0
     5		BR _main<>(SB)
     6	
     7	TEXT _rt0_ppc64le_linux_lib(SB),NOSPLIT,$-8
     8		// Start with standard C stack frame layout and linkage.
     9		MOVD	LR, R0
    10		MOVD	R0, 16(R1) // Save LR in caller's frame.
    11		MOVW	CR, R0     // Save CR in caller's frame
    12		MOVD	R0, 8(R1)
    13		MOVD	R2, 24(R1) // Save TOC in caller's frame.
    14		MOVDU	R1, -320(R1) // Allocate frame.
    15		
    16		// Preserve callee-save registers.
    17		MOVD	R14, 24(R1)
    18		MOVD	R15, 32(R1)
    19		MOVD	R16, 40(R1)
    20		MOVD	R17, 48(R1)
    21		MOVD	R18, 56(R1)
    22		MOVD	R19, 64(R1)
    23		MOVD	R20, 72(R1)
    24		MOVD	R21, 80(R1)
    25		MOVD	R22, 88(R1)
    26		MOVD	R23, 96(R1)
    27		MOVD	R24, 104(R1)
    28		MOVD	R25, 112(R1)
    29		MOVD	R26, 120(R1)
    30		MOVD	R27, 128(R1)
    31		MOVD	R28, 136(R1)
    32		MOVD	R29, 144(R1)
    33		MOVD	g, 152(R1) // R30
    34		MOVD	R31, 160(R1)
    35		FMOVD	F14, 168(R1)
    36		FMOVD	F15, 176(R1)
    37		FMOVD	F16, 184(R1)
    38		FMOVD	F17, 192(R1)
    39		FMOVD	F18, 200(R1)
    40		FMOVD	F19, 208(R1)
    41		FMOVD	F20, 216(R1)
    42		FMOVD	F21, 224(R1)
    43		FMOVD	F22, 232(R1)
    44		FMOVD	F23, 240(R1)
    45		FMOVD	F24, 248(R1)
    46		FMOVD	F25, 256(R1)
    47		FMOVD	F26, 264(R1)
    48		FMOVD	F27, 272(R1)
    49		FMOVD	F28, 280(R1)
    50		FMOVD	F29, 288(R1)
    51		FMOVD	F30, 296(R1)
    52		FMOVD	F31, 304(R1)
    53	
    54		MOVD	R3, _rt0_ppc64le_linux_lib_argc<>(SB)
    55		MOVD	R4, _rt0_ppc64le_linux_lib_argv<>(SB)
    56	
    57		// Synchronous initialization.
    58		MOVD	$runtime·reginit(SB), R12
    59		MOVD	R12, CTR
    60		BL	(CTR)
    61		MOVD	$runtime·libpreinit(SB), R12
    62		MOVD	R12, CTR
    63		BL	(CTR)
    64	
    65		// Create a new thread to do the runtime initialization and return.
    66		MOVD	_cgo_sys_thread_create(SB), R12
    67		CMP	$0, R12
    68		BEQ	nocgo
    69		MOVD	$_rt0_ppc64le_linux_lib_go(SB), R3
    70		MOVD	$0, R4
    71		MOVD	R12, CTR
    72		BL	(CTR)
    73		BR	done
    74	
    75	nocgo:
    76		MOVD	$0x800000, R12                     // stacksize = 8192KB
    77		MOVD	R12, 8(R1)
    78		MOVD	$_rt0_ppc64le_linux_lib_go(SB), R12
    79		MOVD	R12, 16(R1)
    80		MOVD	$runtime·newosproc0(SB),R12
    81		MOVD	R12, CTR
    82		BL	(CTR)
    83	
    84	done:
    85		// Restore saved registers.
    86		MOVD	24(R1), R14
    87		MOVD	32(R1), R15
    88		MOVD	40(R1), R16
    89		MOVD	48(R1), R17
    90		MOVD	56(R1), R18
    91		MOVD	64(R1), R19
    92		MOVD	72(R1), R20
    93		MOVD	80(R1), R21
    94		MOVD	88(R1), R22
    95		MOVD	96(R1), R23
    96		MOVD	104(R1), R24
    97		MOVD	112(R1), R25
    98		MOVD	120(R1), R26
    99		MOVD	128(R1), R27
   100		MOVD	136(R1), R28
   101		MOVD	144(R1), R29
   102		MOVD	152(R1), g // R30
   103		MOVD	160(R1), R31
   104		FMOVD	168(R1), F14
   105		FMOVD	176(R1), F15
   106		FMOVD	184(R1), F16
   107		FMOVD	192(R1), F17
   108		FMOVD	200(R1), F18
   109		FMOVD	208(R1), F19
   110		FMOVD	216(R1), F20
   111		FMOVD	224(R1), F21
   112		FMOVD	232(R1), F22
   113		FMOVD	240(R1), F23
   114		FMOVD	248(R1), F24
   115		FMOVD	256(R1), F25
   116		FMOVD	264(R1), F26
   117		FMOVD	272(R1), F27
   118		FMOVD	280(R1), F28
   119		FMOVD	288(R1), F29
   120		FMOVD	296(R1), F30
   121		FMOVD	304(R1), F31
   122	
   123		ADD	$320, R1
   124		MOVD	24(R1), R2
   125		MOVD	8(R1), R0
   126		MOVFL	R0, $0xff
   127		MOVD	16(R1), R0
   128		MOVD	R0, LR
   129		RET
   130	
   131	TEXT _rt0_ppc64le_linux_lib_go(SB),NOSPLIT,$0
   132		MOVD	_rt0_ppc64le_linux_lib_argc<>(SB), R3
   133		MOVD	_rt0_ppc64le_linux_lib_argv<>(SB), R4
   134		MOVD	$runtime·rt0_go(SB), R12
   135		MOVD	R12, CTR
   136		BR	(CTR)
   137	
   138	DATA _rt0_ppc64le_linux_lib_argc<>(SB)/8, $0
   139	GLOBL _rt0_ppc64le_linux_lib_argc<>(SB),NOPTR, $8
   140	DATA _rt0_ppc64le_linux_lib_argv<>(SB)/8, $0
   141	GLOBL _rt0_ppc64le_linux_lib_argv<>(SB),NOPTR, $8
   142	
   143	TEXT _main<>(SB),NOSPLIT,$-8
   144		// In a statically linked binary, the stack contains argc,
   145		// argv as argc string pointers followed by a NULL, envv as a
   146		// sequence of string pointers followed by a NULL, and auxv.
   147		// There is no TLS base pointer.
   148		//
   149		// In a dynamically linked binary, r3 contains argc, r4
   150		// contains argv, r5 contains envp, r6 contains auxv, and r13
   151		// contains the TLS pointer.
   152		//
   153		// Figure out which case this is by looking at r4: if it's 0,
   154		// we're statically linked; otherwise we're dynamically
   155		// linked.
   156		CMP	R0, R4
   157		BNE	dlink
   158	
   159		// Statically linked
   160		MOVD	0(R1), R3 // argc
   161		ADD	$8, R1, R4 // argv
   162		MOVD	$runtime·m0+m_tls(SB), R13 // TLS
   163		ADD	$0x7000, R13
   164	
   165	dlink:
   166		BR	main(SB)
   167	
   168	TEXT main(SB),NOSPLIT,$-8
   169		MOVD	$runtime·rt0_go(SB), R12
   170		MOVD	R12, CTR
   171		BR	(CTR)

View as plain text