From ade5161f51f2b7239705047875dc36c35139b253 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Tue, 6 Oct 2020 21:13:16 -0400 Subject: [PATCH] crypto/x509: use macOS/AMD64 implementation on macOS/ARM64 Updates #38485. Change-Id: I0582a53171ce803ca1b0237cfa9bc022fc1da6f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/260340 Trust: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- .../x509/internal/macos/corefoundation.go | 2 +- .../x509/internal/macos/corefoundation.s | 2 +- src/crypto/x509/internal/macos/security.go | 2 +- src/crypto/x509/internal/macos/security.s | 2 +- src/crypto/x509/root.go | 2 +- ...cgo_darwin_amd64.go => root_cgo_darwin.go} | 0 .../{root_darwin_amd64.go => root_darwin.go} | 0 .../x509/{root_darwin_iosx.go => root_ios.go} | 4 ++-- ...root_darwin_ios_gen.go => root_ios_gen.go} | 11 ++++------ src/runtime/sys_darwin_arm64.s | 20 +++++++++++++++++++ 10 files changed, 31 insertions(+), 14 deletions(-) rename src/crypto/x509/{root_cgo_darwin_amd64.go => root_cgo_darwin.go} (100%) rename src/crypto/x509/{root_darwin_amd64.go => root_darwin.go} (100%) rename src/crypto/x509/{root_darwin_iosx.go => root_ios.go} (99%) rename src/crypto/x509/{root_darwin_ios_gen.go => root_ios_gen.go} (90%) diff --git a/src/crypto/x509/internal/macos/corefoundation.go b/src/crypto/x509/internal/macos/corefoundation.go index 359694fabf..a248ee3292 100644 --- a/src/crypto/x509/internal/macos/corefoundation.go +++ b/src/crypto/x509/internal/macos/corefoundation.go @@ -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 darwin,amd64 +// +build darwin,!ios // Package macOS provides cgo-less wrappers for Core Foundation and // Security.framework, similarly to how package syscall provides access to diff --git a/src/crypto/x509/internal/macos/corefoundation.s b/src/crypto/x509/internal/macos/corefoundation.s index 8f6be47e4b..a4495d68dd 100644 --- a/src/crypto/x509/internal/macos/corefoundation.s +++ b/src/crypto/x509/internal/macos/corefoundation.s @@ -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 darwin,amd64 +// +build darwin,!ios #include "textflag.h" diff --git a/src/crypto/x509/internal/macos/security.go b/src/crypto/x509/internal/macos/security.go index 64fe206390..59cc19c587 100644 --- a/src/crypto/x509/internal/macos/security.go +++ b/src/crypto/x509/internal/macos/security.go @@ -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 darwin,amd64 +// +build darwin,!ios package macOS diff --git a/src/crypto/x509/internal/macos/security.s b/src/crypto/x509/internal/macos/security.s index 1630c55bab..bd446dbcbe 100644 --- a/src/crypto/x509/internal/macos/security.s +++ b/src/crypto/x509/internal/macos/security.s @@ -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 darwin,amd64 +// +build darwin,!ios #include "textflag.h" diff --git a/src/crypto/x509/root.go b/src/crypto/x509/root.go index da5e91b91c..eccb64121f 100644 --- a/src/crypto/x509/root.go +++ b/src/crypto/x509/root.go @@ -4,7 +4,7 @@ package x509 -//go:generate go run root_darwin_ios_gen.go -version 55161.80.1 +//go:generate go run root_ios_gen.go -version 55161.80.1 import "sync" diff --git a/src/crypto/x509/root_cgo_darwin_amd64.go b/src/crypto/x509/root_cgo_darwin.go similarity index 100% rename from src/crypto/x509/root_cgo_darwin_amd64.go rename to src/crypto/x509/root_cgo_darwin.go diff --git a/src/crypto/x509/root_darwin_amd64.go b/src/crypto/x509/root_darwin.go similarity index 100% rename from src/crypto/x509/root_darwin_amd64.go rename to src/crypto/x509/root_darwin.go diff --git a/src/crypto/x509/root_darwin_iosx.go b/src/crypto/x509/root_ios.go similarity index 99% rename from src/crypto/x509/root_darwin_iosx.go rename to src/crypto/x509/root_ios.go index 5ecc4911b3..98e747733a 100644 --- a/src/crypto/x509/root_darwin_iosx.go +++ b/src/crypto/x509/root_ios.go @@ -1,7 +1,7 @@ -// Code generated by root_darwin_ios_gen.go -version 55161.80.1; DO NOT EDIT. +// Code generated by root_ios_gen.go -version 55161.80.1; DO NOT EDIT. // Update the version in root.go and regenerate with "go generate". -// +build darwin,arm64 darwin,amd64,ios +// +build ios // +build !x509omitbundledroots package x509 diff --git a/src/crypto/x509/root_darwin_ios_gen.go b/src/crypto/x509/root_ios_gen.go similarity index 90% rename from src/crypto/x509/root_darwin_ios_gen.go rename to src/crypto/x509/root_ios_gen.go index 61152b4d11..34dd5d5b22 100644 --- a/src/crypto/x509/root_darwin_ios_gen.go +++ b/src/crypto/x509/root_ios_gen.go @@ -4,7 +4,7 @@ // +build ignore -// Generates root_darwin_iosx.go. +// Generates root_ios.go. // // As of iOS 13, there is no API for querying the system trusted X.509 root // certificates. @@ -37,10 +37,7 @@ import ( ) func main() { - // Temporarily name the file _iosx.go, to avoid restricting it to GOOS=ios, - // as this is also used for darwin/arm64 (macOS). - // TODO: maybe use darwin/amd64 implementation on macOS arm64? - var output = flag.String("output", "root_darwin_iosx.go", "file name to write") + var output = flag.String("output", "root_ios.go", "file name to write") var version = flag.String("version", "", "security_certificates version") flag.Parse() if *version == "" { @@ -159,10 +156,10 @@ func main() { } } -const header = `// Code generated by root_darwin_ios_gen.go -version %s; DO NOT EDIT. +const header = `// Code generated by root_ios_gen.go -version %s; DO NOT EDIT. // Update the version in root.go and regenerate with "go generate". -// +build darwin,arm64 darwin,amd64,ios +// +build ios // +build !x509omitbundledroots package x509 diff --git a/src/runtime/sys_darwin_arm64.s b/src/runtime/sys_darwin_arm64.s index 427cb17781..f8d6f28dc7 100644 --- a/src/runtime/sys_darwin_arm64.s +++ b/src/runtime/sys_darwin_arm64.s @@ -707,3 +707,23 @@ TEXT runtime·syscall6X(SB),NOSPLIT,$0 MOVD R0, 72(R2) // save err ok: RET + +// syscallNoErr is like syscall6 but does not check for errors, and +// only returns one value, for use with standard C ABI library functions. +TEXT runtime·syscallNoErr(SB),NOSPLIT,$0 + SUB $16, RSP // push structure pointer + MOVD R0, (RSP) + + MOVD 0(R0), R12 // fn + MOVD 16(R0), R1 // a2 + MOVD 24(R0), R2 // a3 + MOVD 32(R0), R3 // a4 + MOVD 40(R0), R4 // a5 + MOVD 48(R0), R5 // a6 + MOVD 8(R0), R0 // a1 + BL (R12) + + MOVD (RSP), R2 // pop structure pointer + ADD $16, RSP + MOVD R0, 56(R2) // save r1 + RET -- 2.50.0