From dda4b17ee4866a32a7d0b522f9a366cb6d687ce1 Mon Sep 17 00:00:00 2001 From: qmuntal Date: Mon, 18 Mar 2024 15:38:20 +0100 Subject: [PATCH] runtime: remove nosplit directives from several Windows syscall helpers Some of the Windows syscall helpers don't need to be nosplit. Removing this directive will allow to add instrumentation to these functions without having to worry about the stack size. Change-Id: I3885621f23733af48563803c704563474010b8d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/572415 Reviewed-by: Than McIntosh LUCI-TryBot-Result: Go LUCI Reviewed-by: Cherry Mui --- src/runtime/os_windows.go | 15 --------------- src/runtime/syscall_windows.go | 12 +++--------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go index ce3f224039..b5258bb57d 100644 --- a/src/runtime/os_windows.go +++ b/src/runtime/os_windows.go @@ -304,21 +304,6 @@ func monitorSuspendResume() { uintptr(unsafe.Pointer(¶ms)), uintptr(unsafe.Pointer(&handle))) } -//go:nosplit -func getLoadLibrary() uintptr { - return uintptr(unsafe.Pointer(_LoadLibraryW)) -} - -//go:nosplit -func getLoadLibraryEx() uintptr { - return uintptr(unsafe.Pointer(_LoadLibraryExW)) -} - -//go:nosplit -func getGetProcAddress() uintptr { - return uintptr(unsafe.Pointer(_GetProcAddress)) -} - func getproccount() int32 { var mask, sysmask uintptr ret := stdcall3(_GetProcessAffinityMask, currentProcess, uintptr(unsafe.Pointer(&mask)), uintptr(unsafe.Pointer(&sysmask))) diff --git a/src/runtime/syscall_windows.go b/src/runtime/syscall_windows.go index 7abaea11c8..0b08583563 100644 --- a/src/runtime/syscall_windows.go +++ b/src/runtime/syscall_windows.go @@ -414,10 +414,8 @@ func callbackWrap(a *callbackArgs) { const _LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800 //go:linkname syscall_loadsystemlibrary syscall.loadsystemlibrary -//go:nosplit func syscall_loadsystemlibrary(filename *uint16) (handle, err uintptr) { - fn := getLoadLibraryEx() - handle, _, err = syscall_SyscallN(fn, uintptr(unsafe.Pointer(filename)), 0, _LOAD_LIBRARY_SEARCH_SYSTEM32) + handle, _, err = syscall_SyscallN(uintptr(unsafe.Pointer(_LoadLibraryExW)), uintptr(unsafe.Pointer(filename)), 0, _LOAD_LIBRARY_SEARCH_SYSTEM32) KeepAlive(filename) if handle != 0 { err = 0 @@ -426,10 +424,8 @@ func syscall_loadsystemlibrary(filename *uint16) (handle, err uintptr) { } //go:linkname syscall_loadlibrary syscall.loadlibrary -//go:nosplit func syscall_loadlibrary(filename *uint16) (handle, err uintptr) { - fn := getLoadLibrary() - handle, _, err = syscall_SyscallN(fn, uintptr(unsafe.Pointer(filename))) + handle, _, err = syscall_SyscallN(uintptr(unsafe.Pointer(_LoadLibraryW)), uintptr(unsafe.Pointer(filename))) KeepAlive(filename) if handle != 0 { err = 0 @@ -438,10 +434,8 @@ func syscall_loadlibrary(filename *uint16) (handle, err uintptr) { } //go:linkname syscall_getprocaddress syscall.getprocaddress -//go:nosplit func syscall_getprocaddress(handle uintptr, procname *byte) (outhandle, err uintptr) { - fn := getGetProcAddress() - outhandle, _, err = syscall_SyscallN(fn, handle, uintptr(unsafe.Pointer(procname))) + outhandle, _, err = syscall_SyscallN(uintptr(unsafe.Pointer(_GetProcAddress)), handle, uintptr(unsafe.Pointer(procname))) KeepAlive(procname) if outhandle != 0 { err = 0 -- 2.50.0