aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorWei Xiao <Wei.Xiao@arm.com>2017-08-24 18:24:36 +0800
committerCherry Zhang <cherryyz@google.com>2017-08-28 14:09:35 +0000
commitc195deb48cf09970c6bb77fad96926e0af102dcf (patch)
tree94255a0b30a899a36cf7b1f648bc19dcd50e1147 /src/cmd
parent5d39af9d9bac91b84b9944b1edffc6fb332747fa (diff)
downloadgo-c195deb48cf09970c6bb77fad96926e0af102dcf.tar.xz
cmd/internal/objfile: add arm64 disassembler support
Fixes #19157 Change-Id: Ieea286e8dc03929c3645f3113c33df569f8e26f3 Reviewed-on: https://go-review.googlesource.com/58930 Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/internal/objfile/disasm.go14
-rw-r--r--src/cmd/internal/objfile/elf.go2
-rw-r--r--src/cmd/objdump/objdump_test.go8
3 files changed, 16 insertions, 8 deletions
diff --git a/src/cmd/internal/objfile/disasm.go b/src/cmd/internal/objfile/disasm.go
index d61cb27182..804f47d4ee 100644
--- a/src/cmd/internal/objfile/disasm.go
+++ b/src/cmd/internal/objfile/disasm.go
@@ -22,6 +22,7 @@ import (
"text/tabwriter"
"golang.org/x/arch/arm/armasm"
+ "golang.org/x/arch/arm64/arm64asm"
"golang.org/x/arch/ppc64/ppc64asm"
"golang.org/x/arch/x86/x86asm"
)
@@ -348,6 +349,17 @@ func disasm_arm(code []byte, pc uint64, lookup lookupFunc, _ binary.ByteOrder) (
return text, size
}
+func disasm_arm64(code []byte, pc uint64, lookup lookupFunc, byteOrder binary.ByteOrder) (string, int) {
+ inst, err := arm64asm.Decode(code)
+ var text string
+ if err != nil || inst.Op == 0 {
+ text = "?"
+ } else {
+ text = arm64asm.GoSyntax(inst, pc, lookup, textReader{code, pc})
+ }
+ return text, 4
+}
+
func disasm_ppc64(code []byte, pc uint64, lookup lookupFunc, byteOrder binary.ByteOrder) (string, int) {
inst, err := ppc64asm.Decode(code, byteOrder)
var text string
@@ -365,6 +377,7 @@ var disasms = map[string]disasmFunc{
"386": disasm_386,
"amd64": disasm_amd64,
"arm": disasm_arm,
+ "arm64": disasm_arm64,
"ppc64": disasm_ppc64,
"ppc64le": disasm_ppc64,
}
@@ -373,6 +386,7 @@ var byteOrders = map[string]binary.ByteOrder{
"386": binary.LittleEndian,
"amd64": binary.LittleEndian,
"arm": binary.LittleEndian,
+ "arm64": binary.LittleEndian,
"ppc64": binary.BigEndian,
"ppc64le": binary.LittleEndian,
"s390x": binary.BigEndian,
diff --git a/src/cmd/internal/objfile/elf.go b/src/cmd/internal/objfile/elf.go
index 4ab7e6deb8..4a9013348a 100644
--- a/src/cmd/internal/objfile/elf.go
+++ b/src/cmd/internal/objfile/elf.go
@@ -99,6 +99,8 @@ func (f *elfFile) goarch() string {
return "amd64"
case elf.EM_ARM:
return "arm"
+ case elf.EM_AARCH64:
+ return "arm64"
case elf.EM_PPC64:
if f.elf.ByteOrder == binary.LittleEndian {
return "ppc64le"
diff --git a/src/cmd/objdump/objdump_test.go b/src/cmd/objdump/objdump_test.go
index 47e51df339..491357c962 100644
--- a/src/cmd/objdump/objdump_test.go
+++ b/src/cmd/objdump/objdump_test.go
@@ -155,8 +155,6 @@ func testDisasm(t *testing.T, printCode bool, flags ...string) {
func TestDisasm(t *testing.T) {
switch 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":
@@ -167,8 +165,6 @@ func TestDisasm(t *testing.T) {
func TestDisasmCode(t *testing.T) {
switch 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":
@@ -185,8 +181,6 @@ func TestDisasmExtld(t *testing.T) {
switch runtime.GOARCH {
case "ppc64":
t.Skipf("skipping on %s, no support for external linking, issue 9038", runtime.GOARCH)
- case "arm64":
- t.Skipf("skipping on %s, issue 10106", runtime.GOARCH)
case "mips64", "mips64le", "mips", "mipsle":
t.Skipf("skipping on %s, issue 12559 and 12560", runtime.GOARCH)
case "s390x":
@@ -206,8 +200,6 @@ 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":