Skip to content

Commit c079dd1

Browse files
DanielMorsinggopherbot
authored andcommitted
runtime/secret: reorganize tests to fix -buildmode=shared
The testing assembly methods had a linkname that was implicitly satisfied during the regular build but not there during the shared build. Fix by moving the testing routine into the package itself. For good measure, section off the assembly files from the non-experiment build. Should prevent further build failures as we work on this. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-arm64-longtest Change-Id: I2b45668e44641ae7880ff14f6402d982c7eaedd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/724001 Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Filippo Valsorda <filippo@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
1 parent 2947cb0 commit c079dd1

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

src/runtime/secret/asm_amd64.s

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build goexperiment.runtimesecret
6+
57
// Note: this assembly file is used for testing only.
68
// We need to access registers directly to properly test
79
// that secrets are erased and go test doesn't like to conditionally
@@ -208,6 +210,6 @@ noavx512:
208210
// registers contain secrets.
209211
// It also tests the path from G stack to M stack
210212
// to scheduler and back.
211-
CALL ·delay(SB)
213+
CALL runtime∕secret·delay(SB)
212214

213215
RET

src/runtime/secret/asm_arm64.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build goexperiment.runtimesecret
6+
57
// Note: this assembly file is used for testing only.
68
// We need to access registers directly to properly test
79
// that secrets are erased and go test doesn't like to conditionally

src/runtime/secret/stubs.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build arm64 || amd64
5+
//go:build goexperiment.runtimesecret && (arm64 || amd64)
66

77
// testing stubs, these are implemented in assembly in
88
// asm_$GOARCH.s
@@ -30,3 +30,14 @@ func spillRegisters(p unsafe.Pointer) uintptr
3030
//
3131
//go:noescape
3232
func useSecret(secret []byte)
33+
34+
// callback from assembly
35+
func delay() {
36+
sleep(1_000_000)
37+
}
38+
39+
// linknamed to avoid package importing time
40+
// for just testing code
41+
//
42+
//go:linkname sleep time.Sleep
43+
func sleep(int64)

src/runtime/secret/testdata/crash.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ import (
1818
"weak"
1919
)
2020

21-
// callback from assembly
22-
//
23-
//go:linkname delay main.delay
24-
func delay() {
25-
time.Sleep(1 * time.Millisecond)
26-
}
27-
2821
// Same secret as in ../../crash_test.go
2922
var secretStore = [8]byte{
3023
0x00,

0 commit comments

Comments
 (0)