From: Ian Lance Taylor Date: Tue, 25 Feb 2025 23:40:39 +0000 (-0800) Subject: runtime: route calls to msan_memmove through cgo X-Git-Tag: go1.25rc1~903 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=969a0da362ce846360782b34bfad7a18c2f64628;p=gostls13.git runtime: route calls to msan_memmove through cgo This avoids problems when the C linker doesn't want to see the Go relocation. Fixes #71954 Change-Id: I7cf884c4059d596cad6074ade02020d5a724f20e Reviewed-on: https://go-review.googlesource.com/c/go/+/652180 LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Commit-Queue: Ian Lance Taylor Reviewed-by: Cherry Mui Auto-Submit: Ian Lance Taylor --- diff --git a/src/runtime/msan.go b/src/runtime/msan.go index cb740dc2d8..04378805a8 100644 --- a/src/runtime/msan.go +++ b/src/runtime/msan.go @@ -64,4 +64,4 @@ func msanmove(dst, src unsafe.Pointer, sz uintptr) //go:cgo_import_static __msan_write_go //go:cgo_import_static __msan_malloc_go //go:cgo_import_static __msan_free_go -//go:cgo_import_static __msan_memmove +//go:cgo_import_static __msan_memmove_go diff --git a/src/runtime/msan/msan.go b/src/runtime/msan/msan.go index 7b3e8e608d..8d4471b816 100644 --- a/src/runtime/msan/msan.go +++ b/src/runtime/msan/msan.go @@ -13,6 +13,8 @@ package msan #include #include +extern void __msan_memmove(void*, const void*, uintptr_t); + void __msan_read_go(void *addr, uintptr_t sz) { __msan_check_mem_is_initialized(addr, sz); } @@ -28,5 +30,9 @@ void __msan_malloc_go(void *addr, uintptr_t sz) { void __msan_free_go(void *addr, uintptr_t sz) { __msan_poison(addr, sz); } + +void __msan_memmove_go(void *to, const void *from, uintptr_t sz) { + __msan_memmove(to, from, sz); +} */ import "C" diff --git a/src/runtime/msan_amd64.s b/src/runtime/msan_amd64.s index a1dc388063..aac67c695b 100644 --- a/src/runtime/msan_amd64.s +++ b/src/runtime/msan_amd64.s @@ -63,8 +63,8 @@ TEXT runtime·msanmove(SB), NOSPLIT, $0-24 MOVQ dst+0(FP), RARG0 MOVQ src+8(FP), RARG1 MOVQ sz+16(FP), RARG2 - // void __msan_memmove(void *dst, void *src, uintptr_t sz); - MOVQ $__msan_memmove(SB), AX + // void __msan_memmove_go(void *dst, void *src, uintptr_t sz); + MOVQ $__msan_memmove_go(SB), AX JMP msancall<>(SB) // Switches SP to g0 stack and calls (AX). Arguments already set. diff --git a/src/runtime/msan_arm64.s b/src/runtime/msan_arm64.s index ce475cf44a..044a68e1c7 100644 --- a/src/runtime/msan_arm64.s +++ b/src/runtime/msan_arm64.s @@ -51,8 +51,8 @@ TEXT runtime·msanmove(SB), NOSPLIT, $0-24 MOVD dst+0(FP), RARG0 MOVD src+8(FP), RARG1 MOVD sz+16(FP), RARG2 - // void __msan_memmove(void *dst, void *src, uintptr_t sz); - MOVD $__msan_memmove(SB), FARG + // void __msan_memmove_go(void *dst, void *src, uintptr_t sz); + MOVD $__msan_memmove_go(SB), FARG JMP msancall<>(SB) // Switches SP to g0 stack and calls (FARG). Arguments already set. diff --git a/src/runtime/msan_loong64.s b/src/runtime/msan_loong64.s index b9fa5fd120..71332e2935 100644 --- a/src/runtime/msan_loong64.s +++ b/src/runtime/msan_loong64.s @@ -51,8 +51,8 @@ TEXT runtime·msanmove(SB), NOSPLIT, $0-24 MOVV dst+0(FP), RARG0 MOVV src+8(FP), RARG1 MOVV sz+16(FP), RARG2 - // void __msan_memmove(void *dst, void *src, uintptr_t sz); - MOVV $__msan_memmove(SB), FARG + // void __msan_memmove_go(void *dst, void *src, uintptr_t sz); + MOVV $__msan_memmove_go(SB), FARG JMP msancall<>(SB) // Switches SP to g0 stack and calls (FARG). Arguments already set.