package gosym
 
 import (
-       "bytes"
        "debug/elf"
        "internal/testenv"
        "io/ioutil"
        if err != nil {
                t.Fatal(err)
        }
-       // This command builds pclinetest from pclinetest.asm;
-       // the resulting binary looks like it was built from pclinetest.s,
-       // but we have renamed it to keep it away from the go tool.
        pclinetestBinary = filepath.Join(pclineTempDir, "pclinetest")
-       cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", pclinetestBinary+".o", "pclinetest.asm")
-       cmd.Stdout = os.Stdout
-       cmd.Stderr = os.Stderr
-       if err := cmd.Run(); err != nil {
-               t.Fatal(err)
-       }
-
-       // stamp .o file as being 'package main' so that go tool link will accept it
-       data, err := ioutil.ReadFile(pclinetestBinary + ".o")
-       if err != nil {
-               t.Fatal(err)
-       }
-       i := bytes.IndexByte(data, '\n')
-       if i < 0 {
-               t.Fatal("bad binary")
-       }
-       data = append(append(data[:i:i], "\nmain"...), data[i:]...)
-       if err := ioutil.WriteFile(pclinetestBinary+".o", data, 0666); err != nil {
-               t.Fatal(err)
-       }
-
-       cmd = exec.Command(testenv.GoToolPath(t), "tool", "link", "-H", "linux",
-               "-o", pclinetestBinary, pclinetestBinary+".o")
+       cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", pclinetestBinary)
+       cmd.Dir = "testdata"
+       cmd.Env = append(os.Environ(), "GOOS=linux")
        cmd.Stdout = os.Stdout
        cmd.Stderr = os.Stderr
        if err := cmd.Run(); err != nil {
        }
 
        // Test PCToLine
-       sym := tab.LookupFunc("linefrompc")
+       sym := tab.LookupFunc("main.linefrompc")
        wantLine := 0
        for pc := sym.Entry; pc < sym.End; pc++ {
                off := pc - text.Addr // TODO(rsc): should not need off; bug in 8g
                file, line, fn := tab.PCToLine(pc)
                if fn == nil {
                        t.Errorf("failed to get line of PC %#x", pc)
-               } else if !strings.HasSuffix(file, "pclinetest.asm") || line != wantLine || fn != sym {
-                       t.Errorf("PCToLine(%#x) = %s:%d (%s), want %s:%d (%s)", pc, file, line, fn.Name, "pclinetest.asm", wantLine, sym.Name)
+               } else if !strings.HasSuffix(file, "pclinetest.s") || line != wantLine || fn != sym {
+                       t.Errorf("PCToLine(%#x) = %s:%d (%s), want %s:%d (%s)", pc, file, line, fn.Name, "pclinetest.s", wantLine, sym.Name)
                }
        }
 
        // Test LineToPC
-       sym = tab.LookupFunc("pcfromline")
+       sym = tab.LookupFunc("main.pcfromline")
        lookupline := -1
        wantLine = 0
        off := uint64(0) // TODO(rsc): should not need off; bug in 8g
 
-TEXT linefrompc(SB),4,$0       // Each byte stores its line delta
+TEXT ·linefrompc(SB),4,$0     // Each byte stores its line delta
 BYTE $2;
 BYTE $1;
 BYTE $1; BYTE $0;
 BYTE $2;
 BYTE $255;
 
-TEXT pcfromline(SB),4,$0       // Each record stores its line delta, then n, then n more bytes
+TEXT ·pcfromline(SB),4,$0     // Each record stores its line delta, then n, then n more bytes
 BYTE $32; BYTE $0;
 BYTE $1; BYTE $1; BYTE $0;
 BYTE $1; BYTE $0;
 
 BYTE $4; BYTE $3; BYTE $0; BYTE $0; BYTE $0;
 BYTE $255;
-
-// Keep the linker happy
-TEXT main·main(SB),4,$0
-       RET
-
-TEXT main·init(SB),4,$0
-       // Prevent GC of our test symbols
-       CALL linefrompc(SB)
-       CALL pcfromline(SB)
-       RET