}
testDisasm(t, false, "-ldflags=-linkmode=external")
}
+
+func TestDisasmGoobj(t *testing.T) {
+ switch runtime.GOARCH {
+ case "arm":
+ t.Skipf("skipping on %s, issue 19811", runtime.GOARCH)
+ case "arm64":
+ t.Skipf("skipping on %s, issue 10106", runtime.GOARCH)
+ case "mips", "mipsle", "mips64", "mips64le":
+ t.Skipf("skipping on %s, issue 12559", runtime.GOARCH)
+ case "s390x":
+ t.Skipf("skipping on %s, issue 15255", runtime.GOARCH)
+ }
+
+ hello := filepath.Join(tmp, "hello.o")
+ args := []string{"tool", "compile", "-o", hello}
+ args = append(args, "testdata/fmthello.go")
+ out, err := exec.Command(testenv.GoToolPath(t), args...).CombinedOutput()
+ if err != nil {
+ t.Fatalf("go tool compile fmthello.go: %v\n%s", err, out)
+ }
+ need := []string{
+ "main(SB)",
+ "fmthello.go:6",
+ }
+
+ args = []string{
+ "-s", "main",
+ hello,
+ }
+
+ out, err = exec.Command(exe, args...).CombinedOutput()
+ if err != nil {
+ t.Fatalf("objdump fmthello.o: %v\n%s", err, out)
+ }
+
+ text := string(out)
+ ok := true
+ for _, s := range need {
+ if !strings.Contains(text, s) {
+ t.Errorf("disassembly missing '%s'", s)
+ ok = false
+ }
+ }
+ if !ok {
+ t.Logf("full disassembly:\n%s", text)
+ }
+}