...
Run Format

Text file src/runtime/rt0_linux_ppc64le.s

Documentation: runtime

     1#include "go_asm.h"
     2#include "textflag.h"
     3
     4TEXT _rt0_ppc64le_linux(SB),NOSPLIT,$0
     5	XOR R0, R0	  // Make sure R0 is zero before _main
     6	BR _main<>(SB)
     7
     8TEXT _rt0_ppc64le_linux_lib(SB),NOSPLIT,$-8
     9	// Start with standard C stack frame layout and linkage.
    10	MOVD	LR, R0
    11	MOVD	R0, 16(R1) // Save LR in caller's frame.
    12	MOVW	CR, R0     // Save CR in caller's frame
    13	MOVD	R0, 8(R1)
    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
    75nocgo:
    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
    84done:
    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	8(R1), R0
   125	MOVFL	R0, $0xff
   126	MOVD	16(R1), R0
   127	MOVD	R0, LR
   128	RET
   129
   130TEXT _rt0_ppc64le_linux_lib_go(SB),NOSPLIT,$0
   131	MOVD	_rt0_ppc64le_linux_lib_argc<>(SB), R3
   132	MOVD	_rt0_ppc64le_linux_lib_argv<>(SB), R4
   133	MOVD	$runtime·rt0_go(SB), R12
   134	MOVD	R12, CTR
   135	BR	(CTR)
   136
   137DATA _rt0_ppc64le_linux_lib_argc<>(SB)/8, $0
   138GLOBL _rt0_ppc64le_linux_lib_argc<>(SB),NOPTR, $8
   139DATA _rt0_ppc64le_linux_lib_argv<>(SB)/8, $0
   140GLOBL _rt0_ppc64le_linux_lib_argv<>(SB),NOPTR, $8
   141
   142TEXT _main<>(SB),NOSPLIT,$-8
   143	// In a statically linked binary, the stack contains argc,
   144	// argv as argc string pointers followed by a NULL, envv as a
   145	// sequence of string pointers followed by a NULL, and auxv.
   146	// There is no TLS base pointer.
   147	//
   148	// In a dynamically linked binary, r3 contains argc, r4
   149	// contains argv, r5 contains envp, r6 contains auxv, and r13
   150	// contains the TLS pointer.
   151	//
   152	// Figure out which case this is by looking at r4: if it's 0,
   153	// we're statically linked; otherwise we're dynamically
   154	// linked.
   155	CMP	R0, R4
   156	BNE	dlink
   157
   158	// Statically linked
   159	MOVD	0(R1), R3 // argc
   160	ADD	$8, R1, R4 // argv
   161	MOVD	$runtime·m0+m_tls(SB), R13 // TLS
   162	ADD	$0x7000, R13
   163
   164dlink:
   165	BR	main(SB)
   166
   167TEXT main(SB),NOSPLIT,$-8
   168	MOVD	$runtime·rt0_go(SB), R12
   169	MOVD	R12, CTR
   170	BR	(CTR)

View as plain text