1
2
3
4
5
6
7
8
9 package main
10
11 import (
12 "fmt"
13 "io/ioutil"
14 "os"
15 "os/exec"
16 "path/filepath"
17 "regexp"
18 )
19
20 func main() {
21 err := os.Chdir(filepath.Join("fixedbugs", "issue9355.dir"))
22 check(err)
23
24 f, err := ioutil.TempFile("", "issue9355-*.o")
25 if err != nil {
26 fmt.Println(err)
27 os.Exit(1)
28 }
29 f.Close()
30
31 out := run("go", "tool", "compile", "-p=p", "-o", f.Name(), "-S", "a.go")
32 os.Remove(f.Name())
33
34
35 patterns := []string{
36 `rel 0\+\d t=R_ADDR p\.x\+8\r?\n`,
37 `rel 0\+\d t=R_ADDR p\.x\+(28|1c)\r?\n`,
38 `rel 0\+\d t=R_ADDR p\.b\+5\r?\n`,
39 `rel 0\+\d t=R_ADDR p\.x\+(88|58)\r?\n`,
40 }
41 for _, p := range patterns {
42 if ok, err := regexp.Match(p, out); !ok || err != nil {
43 println(string(out))
44 panic("can't find pattern " + p)
45 }
46 }
47 }
48
49 func run(cmd string, args ...string) []byte {
50 out, err := exec.Command(cmd, args...).CombinedOutput()
51 if err != nil {
52 fmt.Println(string(out))
53 fmt.Println(err)
54 os.Exit(1)
55 }
56 return out
57 }
58
59 func check(err error) {
60 if err != nil {
61 fmt.Println("BUG:", err)
62 os.Exit(1)
63 }
64 }
65
View as plain text