1
0
mirror of https://github.com/golang/go synced 2024-11-18 01:34:44 -07:00

[dev.link] cmd/link: add PPC64 section splitting test

Add a new PPC64-only linker test that does a build with the
-debugppc64textsize debugging option (selecting a lower the threshold
for text section splitting) to verify that no bugs have been
introduced in the linker code that manages this process.

Change-Id: Iea3f16a04c894d528eab2cb52f1ec1d75a2770cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/241499
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Than McIntosh 2020-07-08 11:02:51 -04:00
parent d41b9066da
commit 8370cbe64d

View File

@ -134,3 +134,36 @@ func TestArchiveBuildInvokeWithExec(t *testing.T) {
t.Errorf("expected '%s' in -v output, got:\n%s\n", want, string(out)) t.Errorf("expected '%s' in -v output, got:\n%s\n", want, string(out))
} }
} }
func TestPPC64LargeTextSectionSplitting(t *testing.T) {
// The behavior we're checking for is of interest only on ppc64.
if !strings.HasPrefix(runtime.GOARCH, "ppc64") {
t.Skip("test useful only for ppc64")
}
testenv.MustHaveGoBuild(t)
testenv.MustHaveCGO(t)
t.Parallel()
dir, err := ioutil.TempDir("", "go-build")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
// NB: the use of -ldflags=-debugppc64textsize=1048576 tells the linker to
// split text sections at a size threshold of 1M instead of the
// architected limit of 67M. The choice of building cmd/go is
// arbitrary; we just need something sufficiently large that uses
// external linking.
exe := filepath.Join(dir, "go.exe")
out, eerr := exec.Command(testenv.GoToolPath(t), "build", "-o", exe, "-ldflags=-linkmode=external -debugppc64textsize=1048576", "cmd/go").CombinedOutput()
if eerr != nil {
t.Fatalf("build failure: %s\n%s\n", eerr, string(out))
}
// Result should be runnable.
_, err = exec.Command(exe, "version").CombinedOutput()
if err != nil {
t.Fatal(err)
}
}