diff options
| author | Than McIntosh <thanm@google.com> | 2020-07-08 11:02:51 -0400 |
|---|---|---|
| committer | Than McIntosh <thanm@google.com> | 2020-08-10 11:38:53 +0000 |
| commit | 8370cbe64de345d4635e53202a04712ee6f777e5 (patch) | |
| tree | c3a3f624ae4c0862f81ae049bb51a899eeee8e3d /src/cmd | |
| parent | d41b9066dad9091c55e2b6e6c48ceaee7dff1cf6 (diff) | |
| download | go-8370cbe64de345d4635e53202a04712ee6f777e5.tar.xz | |
[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>
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/link/internal/ld/ld_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/cmd/link/internal/ld/ld_test.go b/src/cmd/link/internal/ld/ld_test.go index 4dbe09d586..db339b484d 100644 --- a/src/cmd/link/internal/ld/ld_test.go +++ b/src/cmd/link/internal/ld/ld_test.go @@ -134,3 +134,36 @@ func TestArchiveBuildInvokeWithExec(t *testing.T) { 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) + } +} |
