ppc64/ppc64asm: first round of fixes
- make test pass on 32-bit systems
- make test skip objdump when objdump not available,
like in the other architecture tests
- expose plan9Syntax as GoSyntax
Change-Id: I8b1bb7cc4a07c6bd8a4eb0569553cb47773fb2a4
Reviewed-on: https://go-review.googlesource.com/30934
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/ppc64/ppc64asm/decode_test.go b/ppc64/ppc64asm/decode_test.go
index 735cb2f..71f64d6 100644
--- a/ppc64/ppc64asm/decode_test.go
+++ b/ppc64/ppc64asm/decode_test.go
@@ -51,7 +51,7 @@
case "gnu":
out = GNUSyntax(inst)
//case "plan9":
- // out = plan9Syntax(inst, 0, nil, nil)
+ // out = GoSyntax(inst, 0, nil, nil)
default:
t.Errorf("unknown syntax %q", syntax)
continue
diff --git a/ppc64/ppc64asm/ext_test.go b/ppc64/ppc64asm/ext_test.go
index 443326c..01abefb 100644
--- a/ppc64/ppc64asm/ext_test.go
+++ b/ppc64/ppc64asm/ext_test.go
@@ -246,7 +246,7 @@
case "gnu":
text = GNUSyntax(inst)
//case "plan9":
- // text = plan9Syntax(inst, 0, nil)
+ // text = GoSyntax(inst, 0, nil)
default:
text = "error: unknown syntax " + syntax
}
diff --git a/ppc64/ppc64asm/gnu.go b/ppc64/ppc64asm/gnu.go
index 1ea3ab5..63be379 100644
--- a/ppc64/ppc64asm/gnu.go
+++ b/ppc64/ppc64asm/gnu.go
@@ -68,7 +68,7 @@
case PCRel:
return fmt.Sprintf(".%+#x", int(arg))
case Label:
- return fmt.Sprintf("%#x", int(arg))
+ return fmt.Sprintf("%#x", uint32(arg))
case Offset:
reg := inst.Args[argIndex+1].(Reg)
removeArg(inst, argIndex+1)
diff --git a/ppc64/ppc64asm/objdumpext_test.go b/ppc64/ppc64asm/objdumpext_test.go
index 413a626..64dd274 100644
--- a/ppc64/ppc64asm/objdumpext_test.go
+++ b/ppc64/ppc64asm/objdumpext_test.go
@@ -22,10 +22,10 @@
const objdumpPath = "/usr/local/bin/powerpc64-unknown-linux-gnu-objdump"
func testObjdump(t *testing.T, generate func(func([]byte))) {
+ if testing.Short() {
+ t.Skip("skipping objdump test in short mode")
+ }
if _, err := os.Stat(objdumpPath); err != nil {
- if !testing.Short() {
- t.Fatal(err)
- }
t.Skip(err)
}
diff --git a/ppc64/ppc64asm/plan9.go b/ppc64/ppc64asm/plan9.go
index b0b5270..f9bafb9 100644
--- a/ppc64/ppc64asm/plan9.go
+++ b/ppc64/ppc64asm/plan9.go
@@ -9,14 +9,13 @@
"strings"
)
-// plan9Syntax returns the Go assembler syntax for the instruction.
-// The syntax was originally defined by Plan 9.
+// GoSyntax returns the Go assembler syntax for the instruction.
// The pc is the program counter of the first instruction, used for expanding
// PC-relative addresses into absolute ones.
// The symname function queries the symbol table for the program
// being disassembled. It returns the name and base address of the symbol
// containing the target, if any; otherwise it returns "", 0.
-func plan9Syntax(inst Inst, pc uint64, symname func(uint64) (string, uint64)) string {
+func GoSyntax(inst Inst, pc uint64, symname func(uint64) (string, uint64)) string {
if symname == nil {
symname = func(uint64) (string, uint64) { return "", 0 }
}
@@ -67,6 +66,7 @@
} else if int(inst.Args[0].(Imm))&0x1c == 4 && revCondMap[args[1]] != "" { // jump on cond bit not set
return fmt.Sprintf("B%s %s", revCondMap[args[1]], args[2])
}
+ return op + " " + strings.Join(args, ", ")
case BCCTR:
if int(inst.Args[0].(Imm))&20 == 20 { // unconditional
return "BR (CTR)"
@@ -80,7 +80,6 @@
case BCA, BCL, BCLA, BCLRL, BCTAR, BCTARL:
return op + " " + strings.Join(args, ", ")
}
- panic("unreachable")
}
// plan9Arg formats arg (which is the argIndex's arg in inst) according to Plan 9 rules.