aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/cgo/gcc_libinit_windows.c23
-rw-r--r--src/runtime/syscall_windows_test.go15
2 files changed, 38 insertions, 0 deletions
diff --git a/src/runtime/cgo/gcc_libinit_windows.c b/src/runtime/cgo/gcc_libinit_windows.c
index 78b32254cf..ed30878c3c 100644
--- a/src/runtime/cgo/gcc_libinit_windows.c
+++ b/src/runtime/cgo/gcc_libinit_windows.c
@@ -14,6 +14,29 @@
#include "libcgo.h"
+#define IMAGE_GUARD_SECURITY_COOKIE_UNUSED 0x00000800
+// With modern mingw, we can use the normal struct:
+//
+// const IMAGE_LOAD_CONFIG_DIRECTORY _load_config_used = {
+// .Size = sizeof(_load_config_used),
+// .GuardFlags = IMAGE_GUARD_SECURITY_COOKIE_UNUSED
+// };
+//
+// But we support older toolchains, so instead, fix the offsets:
+#ifdef _WIN64
+const ULONGLONG _load_config_used[40] = {
+ sizeof(_load_config_used),
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ IMAGE_GUARD_SECURITY_COOKIE_UNUSED
+};
+#else
+const DWORD _load_config_used[48] = {
+ sizeof(_load_config_used),
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ IMAGE_GUARD_SECURITY_COOKIE_UNUSED
+};
+#endif
+
static volatile LONG runtime_init_once_gate = 0;
static volatile LONG runtime_init_once_done = 0;
diff --git a/src/runtime/syscall_windows_test.go b/src/runtime/syscall_windows_test.go
index 77092d8fbf..437c723d51 100644
--- a/src/runtime/syscall_windows_test.go
+++ b/src/runtime/syscall_windows_test.go
@@ -8,6 +8,7 @@ import (
"fmt"
"internal/abi"
"internal/race"
+ "internal/syscall/windows"
"internal/syscall/windows/sysdll"
"internal/testenv"
"io"
@@ -1226,6 +1227,20 @@ var (
procSetEvent = modkernel32.NewProc("SetEvent")
)
+func TestTrueVersion(t *testing.T) {
+ ver, err := syscall.GetVersion()
+ if err != nil {
+ t.Fatalf("GetVersion failed: %v", err)
+ }
+ wantMajor, wantMinor, wantBuild := windows.Version()
+ major := uint32(byte(ver))
+ minor := uint32(uint8(ver >> 8))
+ build := uint32(uint16(ver >> 16))
+ if major != wantMajor || minor != wantMinor || build != wantBuild {
+ t.Errorf("GetVersion = %d.%d (Build %d), want %d.%d (Build %d)", major, minor, build, wantMajor, wantMinor, wantBuild)
+ }
+}
+
func createEvent() (syscall.Handle, error) {
r0, _, e0 := syscall.Syscall6(procCreateEvent.Addr(), 4, 0, 0, 0, 0, 0, 0)
if r0 == 0 {