mirror of
https://github.com/golang/go
synced 2024-09-30 08:28:34 -06:00
runtime: add msan support on freebsd/amd64
Adjust build constraints and change the runtime to call the C mmap function when using cgo. R=go1.20 For #53298 Change-Id: If9c3306dc16a8645d1bb9be0343e0472d6c4783f Reviewed-on: https://go-review.googlesource.com/c/go/+/411274 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
76e4833b7a
commit
5fde02e312
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build linux,amd64 linux,arm64 linux,ppc64le
|
||||
// +build linux,amd64 linux,arm64 linux,ppc64le freebsd,amd64
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build (linux && amd64) || (linux && arm64)
|
||||
//go:build (linux && amd64) || (linux && arm64) || (freebsd && amd64)
|
||||
|
||||
package cgo
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// Support for memory sanitizer. See runtime/cgo/mmap.go.
|
||||
|
||||
//go:build (linux && amd64) || (linux && arm64)
|
||||
//go:build (linux && amd64) || (linux && arm64) || (freebsd && amd64)
|
||||
|
||||
package runtime
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !aix && !darwin && !js && (!linux || !amd64) && (!linux || !arm64) && !openbsd && !plan9 && !solaris && !windows
|
||||
//go:build !aix && !darwin && !js && (!linux || !amd64) && (!linux || !arm64) && (!freebsd || !amd64) && !openbsd && !plan9 && !solaris && !windows
|
||||
|
||||
package runtime
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build msan && linux && (amd64 || arm64)
|
||||
//go:build msan && ((linux && (amd64 || arm64)) || (freebsd && amd64))
|
||||
|
||||
package msan
|
||||
|
||||
|
@ -385,7 +385,7 @@ sigtrampnog:
|
||||
MOVQ _cgo_callers(SB), AX
|
||||
JMP AX
|
||||
|
||||
TEXT runtime·mmap(SB),NOSPLIT,$0
|
||||
TEXT runtime·sysMmap(SB),NOSPLIT,$0
|
||||
MOVQ addr+0(FP), DI // arg 1 addr
|
||||
MOVQ n+8(FP), SI // arg 2 len
|
||||
MOVL prot+16(FP), DX // arg 3 prot
|
||||
@ -403,7 +403,25 @@ ok:
|
||||
MOVQ $0, err+40(FP)
|
||||
RET
|
||||
|
||||
TEXT runtime·munmap(SB),NOSPLIT,$0
|
||||
// Call the function stored in _cgo_mmap using the GCC calling convention.
|
||||
// This must be called on the system stack.
|
||||
TEXT runtime·callCgoMmap(SB),NOSPLIT,$16
|
||||
MOVQ addr+0(FP), DI
|
||||
MOVQ n+8(FP), SI
|
||||
MOVL prot+16(FP), DX
|
||||
MOVL flags+20(FP), CX
|
||||
MOVL fd+24(FP), R8
|
||||
MOVL off+28(FP), R9
|
||||
MOVQ _cgo_mmap(SB), AX
|
||||
MOVQ SP, BX
|
||||
ANDQ $~15, SP // alignment as per amd64 psABI
|
||||
MOVQ BX, 0(SP)
|
||||
CALL AX
|
||||
MOVQ 0(SP), SP
|
||||
MOVQ AX, ret+32(FP)
|
||||
RET
|
||||
|
||||
TEXT runtime·sysMunmap(SB),NOSPLIT,$0
|
||||
MOVQ addr+0(FP), DI // arg 1 addr
|
||||
MOVQ n+8(FP), SI // arg 2 len
|
||||
MOVL $SYS_munmap, AX
|
||||
@ -412,6 +430,19 @@ TEXT runtime·munmap(SB),NOSPLIT,$0
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
// Call the function stored in _cgo_munmap using the GCC calling convention.
|
||||
// This must be called on the system stack.
|
||||
TEXT runtime·callCgoMunmap(SB),NOSPLIT,$16-16
|
||||
MOVQ addr+0(FP), DI
|
||||
MOVQ n+8(FP), SI
|
||||
MOVQ _cgo_munmap(SB), AX
|
||||
MOVQ SP, BX
|
||||
ANDQ $~15, SP // alignment as per amd64 psABI
|
||||
MOVQ BX, 0(SP)
|
||||
CALL AX
|
||||
MOVQ 0(SP), SP
|
||||
RET
|
||||
|
||||
TEXT runtime·madvise(SB),NOSPLIT,$0
|
||||
MOVQ addr+0(FP), DI
|
||||
MOVQ n+8(FP), SI
|
||||
|
Loading…
Reference in New Issue
Block a user