diff options
author | Cherry Mui <cherryyz@google.com> | 2024-05-16 17:19:15 -0400 |
---|---|---|
committer | Cherry Mui <cherryyz@google.com> | 2024-05-17 16:48:00 +0000 |
commit | 41aab30bd260297ad8ddad47e98fdf8390a9a67e (patch) | |
tree | 35f0a55a0bf582f2df6faa2be02e185db43dabcc /src/cmd | |
parent | f73dd8173a2d459113254dbd71d47856b5be0441 (diff) | |
download | go-41aab30bd260297ad8ddad47e98fdf8390a9a67e.tar.gz go-41aab30bd260297ad8ddad47e98fdf8390a9a67e.zip |
all: add push linknames to allow legacy pull linknames
CL 585358 adds restrictions to disallow pull-only linknames
(currently off by default). Currently, there are quite some pull-
only linknames in user code in the wild. In order not to break
those, we add push linknames to allow them to be pulled. This CL
includes linknames found in a large code corpus (thanks Matthew
Dempsky and Michael Pratt for the analysis!), that are not
currently linknamed.
Updates #67401.
Change-Id: I32f5fc0c7a6abbd7a11359a025cfa2bf458fe767
Reviewed-on: https://go-review.googlesource.com/c/go/+/586137
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/link/link_test.go | 1 | ||||
-rw-r--r-- | src/cmd/link/testdata/linkname/badlinkname.go | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/cmd/link/link_test.go b/src/cmd/link/link_test.go index 1ce484fe61..e33494f7f1 100644 --- a/src/cmd/link/link_test.go +++ b/src/cmd/link/link_test.go @@ -1440,6 +1440,7 @@ func TestCheckLinkname(t *testing.T) { {"coro2.go", false}, // legacy bad linkname is ok, for now {"fastrand.go", true}, + {"badlinkname.go", true}, } for _, test := range tests { test := test diff --git a/src/cmd/link/testdata/linkname/badlinkname.go b/src/cmd/link/testdata/linkname/badlinkname.go new file mode 100644 index 0000000000..fb9f9c6b7d --- /dev/null +++ b/src/cmd/link/testdata/linkname/badlinkname.go @@ -0,0 +1,24 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Existing pull linknames in the wild are allowed _for now_, +// for legacy reason. Test a function and a method. +// NOTE: this may not be allowed in the future. Don't do this! + +package main + +import ( + _ "reflect" + "unsafe" +) + +//go:linkname noescape runtime.noescape +func noescape(unsafe.Pointer) unsafe.Pointer + +//go:linkname rtype_String reflect.(*rtype).String +func rtype_String(unsafe.Pointer) string + +func main() { + println(rtype_String(noescape(nil))) +} |