diff options
author | Christopher Nelson <nadiasvertex@gmail.com> | 2015-12-13 08:02:29 -0500 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2016-04-04 03:38:25 +0000 |
commit | ed8f0e5c33269de2f950d33ab7d50554b13f336e (patch) | |
tree | 082a9afa5121f0ca714f2b45ecbcac58db86de10 /src/runtime/rt0_windows_amd64.s | |
parent | 386c0e6598eadab18e01d3fa60f8e21872cbe70c (diff) | |
download | go-ed8f0e5c33269de2f950d33ab7d50554b13f336e.tar.gz go-ed8f0e5c33269de2f950d33ab7d50554b13f336e.zip |
cmd/go: fix -buildmode=c-archive should work on windows
Add supporting code for runtime initialization, including both
32- and 64-bit x86 architectures.
Add .ctors section on Windows to PE .o files, and INITENTRY to .ctors
section to plug in to the GCC C/C++ startup initialization mechanism.
This allows the Go runtime to initialize itself. Add .text section
symbol for .ctor relocations. Note: This is unlikely to be useful for
MSVC-based toolchains.
Fixes #13494
Change-Id: I4286a96f70e5f5228acae88eef46e2bed95813f3
Reviewed-on: https://go-review.googlesource.com/18057
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/rt0_windows_amd64.s')
-rw-r--r-- | src/runtime/rt0_windows_amd64.s | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/runtime/rt0_windows_amd64.s b/src/runtime/rt0_windows_amd64.s index 95dce06d71..2f73b37f31 100644 --- a/src/runtime/rt0_windows_amd64.s +++ b/src/runtime/rt0_windows_amd64.s @@ -12,6 +12,37 @@ TEXT _rt0_amd64_windows(SB),NOSPLIT,$-8 MOVQ $main(SB), AX JMP AX +// When building with -buildmode=(c-shared or c-archive), this +// symbol is called. For dynamic libraries it is called when the +// library is loaded. For static libraries it is called when the +// final executable starts, during the C runtime initialization +// phase. +TEXT _rt0_amd64_windows_lib(SB),NOSPLIT,$0x28 + MOVQ BP, 0x00(SP) + MOVQ BX, 0x08(SP) + MOVQ AX, 0x10(SP) + MOVQ CX, 0x18(SP) + MOVQ DX, 0x20(SP) + + // Create a new thread to do the runtime initialization and return. + MOVQ _cgo_sys_thread_create(SB), AX + MOVQ $_rt0_amd64_windows_lib_go(SB), CX + MOVQ $0, DX + CALL AX + + MOVQ 0x00(SP), BP + MOVQ 0x08(SP), BX + MOVQ 0x10(SP), AX + MOVQ 0x18(SP), CX + MOVQ 0x20(SP), DX + RET + +TEXT _rt0_amd64_windows_lib_go(SB),NOSPLIT,$0 + MOVQ $0, DI + MOVQ $0, SI + MOVQ $runtime·rt0_go(SB), AX + JMP AX + TEXT main(SB),NOSPLIT,$-8 MOVQ $runtime·rt0_go(SB), AX JMP AX |