]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/objfile: add arm64 disassembler support
authorWei Xiao <Wei.Xiao@arm.com>
Thu, 24 Aug 2017 10:24:36 +0000 (18:24 +0800)
committerCherry Zhang <cherryyz@google.com>
Mon, 28 Aug 2017 14:09:35 +0000 (14:09 +0000)
Fixes #19157

Change-Id: Ieea286e8dc03929c3645f3113c33df569f8e26f3
Reviewed-on: https://go-review.googlesource.com/58930
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/internal/objfile/disasm.go
src/cmd/internal/objfile/elf.go
src/cmd/objdump/objdump_test.go

index d61cb27182dd39e99d2ffc56286b631f710f1ce6..804f47d4eed7bb7ecba69b0556e28e8a68864ee4 100644 (file)
@@ -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,
index 4ab7e6deb812e0ce1d0a57efbd6576ef7bed8b9a..4a9013348aa06b083d195fcb83c305ff99eae1a7 100644 (file)
@@ -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"
index 47e51df3392f001dece0f2b807010ee14d614f5b..491357c96205fbe04b358aa143abec7edd1fd42d 100644 (file)
@@ -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":