]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: add PPC64 section splitting test
authorThan McIntosh <thanm@google.com>
Wed, 8 Jul 2020 15:02:51 +0000 (11:02 -0400)
committerThan McIntosh <thanm@google.com>
Mon, 10 Aug 2020 11:38:53 +0000 (11:38 +0000)
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>
src/cmd/link/internal/ld/ld_test.go

index 4dbe09d58611149f788e17af7de16c88126a4d41..db339b484d83df8aff44ed4820fca9cea89d1f73 100644 (file)
@@ -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)
+       }
+}