From f5616ed2fecc4f33efb8e0b8a2978c7fb0382c81 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 18 Aug 2024 23:28:52 -0400 Subject: [PATCH] =?UTF-8?q?all:=20document=20legacy=20//go:linkname=20for?= =?UTF-8?q?=20modules=20with=20=E2=89=A55,000=20dependents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For #67401. Change-Id: Ifea84af92017b405466937f50fb8f28e6893c8cb Reviewed-on: https://go-review.googlesource.com/c/go/+/587220 Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI Auto-Submit: Russ Cox --- badlinkname.go | 3 --- cipher_suites.go | 10 ++++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/badlinkname.go b/badlinkname.go index 8555896..b83c7f6 100644 --- a/badlinkname.go +++ b/badlinkname.go @@ -14,9 +14,6 @@ import _ "unsafe" //go:linkname aeadAESGCMTLS13 //go:linkname cipherSuiteTLS13ByID -//go:linkname cipherSuitesTLS13 -//go:linkname defaultCipherSuitesTLS13 -//go:linkname defaultCipherSuitesTLS13NoAES //go:linkname errShutdown // The compiler doesn't allow linknames on methods, for good reasons. diff --git a/cipher_suites.go b/cipher_suites.go index 438f428..fa90fe9 100644 --- a/cipher_suites.go +++ b/cipher_suites.go @@ -16,6 +16,7 @@ import ( "fmt" "hash" "runtime" + _ "unsafe" // for linkname "golang.org/x/crypto/chacha20poly1305" "golang.org/x/sys/cpu" @@ -196,6 +197,15 @@ type cipherSuiteTLS13 struct { hash crypto.Hash } +// cipherSuitesTLS13 should be an internal detail, +// but widely used packages access it using linkname. +// Notable members of the hall of shame include: +// - github.com/quic-go/quic-go +// +// Do not remove or change the type signature. +// See go.dev/issue/67401. +// +//go:linkname cipherSuitesTLS13 var cipherSuitesTLS13 = []*cipherSuiteTLS13{ // TODO: replace with a map. {TLS_AES_128_GCM_SHA256, 16, aeadAESGCMTLS13, crypto.SHA256}, {TLS_CHACHA20_POLY1305_SHA256, 32, aeadChaCha20Poly1305, crypto.SHA256},