]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "cmd/link: skip symbol references when looking for missing symbols"
authorAustin Clements <austin@google.com>
Mon, 6 Jan 2020 15:32:43 +0000 (15:32 +0000)
committerAustin Clements <austin@google.com>
Mon, 6 Jan 2020 15:56:20 +0000 (15:56 +0000)
This reverts commit 8adc1e00aa1a92a85b9d6f3526419d49dd7859dd.

Reason for revert: The test added in this commit fails on several
builders.

Fixes #36389. Re-opens #33979.

Change-Id: I31191098c36af00f7688749b3376686673b3ac68
Reviewed-on: https://go-review.googlesource.com/c/go/+/213417
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
src/cmd/link/internal/ld/link.go
src/cmd/link/link_test.go

index df3845fac3c4d61ea1d7f2ac67fb97f12b579ab3..124f7d9001fcad1e551a689b0f7d2e95386cc16a 100644 (file)
@@ -136,7 +136,7 @@ func (ctxt *Link) ErrorUnresolved(s *sym.Symbol, r *sym.Reloc) {
                                if v == -1 {
                                        continue
                                }
-                               if rs := ctxt.Syms.ROLookup(r.Sym.Name, v); rs != nil && rs.Type != sym.Sxxx && rs.Type != sym.SXREF {
+                               if rs := ctxt.Syms.ROLookup(r.Sym.Name, v); rs != nil && rs.Type != sym.Sxxx {
                                        haveABI = abi
                                }
                        }
index 1a86638c2f5d536f125c3ed2798c6d73b0377ed8..1515f97558402516cd091fef0b3caa5c5f13e4cf 100644 (file)
@@ -172,85 +172,6 @@ main.x: relocation target main.zero not defined
        }
 }
 
-func TestIssue33979(t *testing.T) {
-       testenv.MustHaveGoBuild(t)
-       testenv.MustHaveCGO(t)
-
-       tmpdir, err := ioutil.TempDir("", "unresolved-")
-       if err != nil {
-               t.Fatalf("failed to create temp dir: %v", err)
-       }
-       defer os.RemoveAll(tmpdir)
-
-       write := func(name, content string) {
-               err := ioutil.WriteFile(filepath.Join(tmpdir, name), []byte(content), 0666)
-               if err != nil {
-                       t.Fatal(err)
-               }
-       }
-
-       run := func(name string, args ...string) string {
-               cmd := exec.Command(name, args...)
-               cmd.Dir = tmpdir
-               out, err := cmd.CombinedOutput()
-               if err != nil {
-                       t.Fatalf("'go %s' failed: %v, output: %s", strings.Join(args, " "), err, out)
-               }
-               return string(out)
-       }
-       runGo := func(args ...string) string {
-               return run(testenv.GoToolPath(t), args...)
-       }
-
-       // Test object with undefined reference that was not generated
-       // by Go, resulting in an SXREF symbol being loaded during linking.
-       // Because of issue #33979, the SXREF symbol would be found during
-       // error reporting, resulting in confusing error messages.
-
-       write("main.go", `package main
-func main() {
-        x()
-}
-func x()
-`)
-       // The following assembly must work on all architectures.
-       write("x.s", `
-TEXT ·x(SB),0,$0
-        CALL foo(SB)
-        RET
-`)
-       write("x.c", `
-void undefined();
-
-void foo() {
-        undefined();
-}
-`)
-
-       cc := strings.TrimSpace(runGo("env", "CC"))
-       cflags := strings.Fields(runGo("env", "GOGCCFLAGS"))
-
-       // Compile, assemble and pack the Go and C code.
-       runGo("tool", "asm", "-gensymabis", "-o", "symabis", "x.s")
-       runGo("tool", "compile", "-symabis", "symabis", "-p", "main", "-o", "x1.o", "main.go")
-       runGo("tool", "asm", "-o", "x2.o", "x.s")
-       run(cc, append(cflags, "-c", "-o", "x3.o", "x.c")...)
-       runGo("tool", "pack", "c", "x.a", "x1.o", "x2.o", "x3.o")
-
-       // Now attempt to link using the internal linker.
-       cmd := exec.Command(testenv.GoToolPath(t), "tool", "link", "-linkmode=internal", "x.a")
-       cmd.Dir = tmpdir
-       out, err := cmd.CombinedOutput()
-       if err == nil {
-               t.Fatalf("expected link to fail, but it succeeded")
-       }
-       got := string(out)
-       want := "main(.text): relocation target undefined not defined\n"
-       if !strings.Contains(got, want) {
-               t.Fatalf("got:\n%swant:\n%s", got, want)
-       }
-}
-
 func TestBuildForTvOS(t *testing.T) {
        testenv.MustHaveCGO(t)
        testenv.MustHaveGoBuild(t)