1// Copyright 2011 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 "go_asm.h" 6#include "go_tls.h" 7#include "textflag.h" 8 9TEXT _rt0_amd64_windows(SB),NOSPLIT|NOFRAME,$-8 10 JMP _rt0_amd64(SB) 11 12// When building with -buildmode=(c-shared or c-archive), this 13// symbol is called. For dynamic libraries it is called when the 14// library is loaded. For static libraries it is called when the 15// final executable starts, during the C runtime initialization 16// phase. 17// Leave space for four pointers on the stack as required 18// by the Windows amd64 calling convention. 19TEXT _rt0_amd64_windows_lib(SB),NOSPLIT|NOFRAME,$40 20 // Create a new thread to do the runtime initialization and return. 21 MOVQ BX, 32(SP) // callee-saved, preserved across the CALL 22 MOVQ SP, BX 23 ANDQ $~15, SP // alignment as per Windows requirement 24 MOVQ _cgo_sys_thread_create(SB), AX 25 MOVQ $_rt0_amd64_windows_lib_go(SB), CX 26 MOVQ $0, DX 27 CALL AX 28 MOVQ BX, SP 29 MOVQ 32(SP), BX 30 RET 31 32TEXT _rt0_amd64_windows_lib_go(SB),NOSPLIT|NOFRAME,$0 33 MOVQ $0, DI 34 MOVQ $0, SI 35 MOVQ $runtime·rt0_go(SB), AX 36 JMP AX 37