aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dist
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-02-09 17:01:53 -0500
committerCherry Zhang <cherryyz@google.com>2020-02-21 23:11:00 +0000
commit3e4e644433cca68118eaa3878b88dddfa5352af5 (patch)
treee60e19948f9983b41f2abbdb483d600785b859b7 /src/cmd/dist
parentffc0573b854ca2fc58ad85ad7599ec66f0a82b36 (diff)
downloadgo-3e4e644433cca68118eaa3878b88dddfa5352af5.tar.xz
cmd/dist: test cgo internal linking PIE
On platforms where internal linking PIE is supported, run misc/cgo/test with that configuration. Change-Id: Ia09631b07cc469c85818e1494093d802ea9d69a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/218838 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/cmd/dist')
-rw-r--r--src/cmd/dist/test.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index 56bdfcac19..1869fb5b2d 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -581,7 +581,7 @@ func (t *tester) registerTests() {
}
// Test internal linking of PIE binaries where it is supported.
- if goos == "linux" && (goarch == "amd64" || goarch == "arm64") {
+ if t.internalLinkPIE() {
t.tests = append(t.tests, distTest{
name: "pie_internal",
heading: "internal linking of -buildmode=pie",
@@ -936,6 +936,10 @@ func (t *tester) internalLink() bool {
return true
}
+func (t *tester) internalLinkPIE() bool {
+ return goos == "linux" && (goarch == "amd64" || goarch == "arm64")
+}
+
func (t *tester) supportedBuildmode(mode string) bool {
pair := goos + "-" + goarch
switch mode {
@@ -1110,6 +1114,9 @@ func (t *tester) cgoTest(dt *distTest) error {
if t.supportedBuildmode("pie") {
t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie")
+ if t.internalLinkPIE() {
+ t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", "-ldflags=-linkmode=internal")
+ }
t.addCmd(dt, "misc/cgo/testtls", t.goTest(), "-buildmode=pie")
t.addCmd(dt, "misc/cgo/nocgo", t.goTest(), "-buildmode=pie")
}