1
0
mirror of https://github.com/golang/go synced 2024-11-19 14:24:47 -07:00

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>
This commit is contained in:
Wei Xiao 2017-08-24 18:24:36 +08:00 committed by Cherry Zhang
parent 5d39af9d9b
commit c195deb48c
3 changed files with 16 additions and 8 deletions

View File

@ -22,6 +22,7 @@ import (
"text/tabwriter" "text/tabwriter"
"golang.org/x/arch/arm/armasm" "golang.org/x/arch/arm/armasm"
"golang.org/x/arch/arm64/arm64asm"
"golang.org/x/arch/ppc64/ppc64asm" "golang.org/x/arch/ppc64/ppc64asm"
"golang.org/x/arch/x86/x86asm" "golang.org/x/arch/x86/x86asm"
) )
@ -348,6 +349,17 @@ func disasm_arm(code []byte, pc uint64, lookup lookupFunc, _ binary.ByteOrder) (
return text, size 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) { func disasm_ppc64(code []byte, pc uint64, lookup lookupFunc, byteOrder binary.ByteOrder) (string, int) {
inst, err := ppc64asm.Decode(code, byteOrder) inst, err := ppc64asm.Decode(code, byteOrder)
var text string var text string
@ -365,6 +377,7 @@ var disasms = map[string]disasmFunc{
"386": disasm_386, "386": disasm_386,
"amd64": disasm_amd64, "amd64": disasm_amd64,
"arm": disasm_arm, "arm": disasm_arm,
"arm64": disasm_arm64,
"ppc64": disasm_ppc64, "ppc64": disasm_ppc64,
"ppc64le": disasm_ppc64, "ppc64le": disasm_ppc64,
} }
@ -373,6 +386,7 @@ var byteOrders = map[string]binary.ByteOrder{
"386": binary.LittleEndian, "386": binary.LittleEndian,
"amd64": binary.LittleEndian, "amd64": binary.LittleEndian,
"arm": binary.LittleEndian, "arm": binary.LittleEndian,
"arm64": binary.LittleEndian,
"ppc64": binary.BigEndian, "ppc64": binary.BigEndian,
"ppc64le": binary.LittleEndian, "ppc64le": binary.LittleEndian,
"s390x": binary.BigEndian, "s390x": binary.BigEndian,

View File

@ -99,6 +99,8 @@ func (f *elfFile) goarch() string {
return "amd64" return "amd64"
case elf.EM_ARM: case elf.EM_ARM:
return "arm" return "arm"
case elf.EM_AARCH64:
return "arm64"
case elf.EM_PPC64: case elf.EM_PPC64:
if f.elf.ByteOrder == binary.LittleEndian { if f.elf.ByteOrder == binary.LittleEndian {
return "ppc64le" return "ppc64le"

View File

@ -155,8 +155,6 @@ func testDisasm(t *testing.T, printCode bool, flags ...string) {
func TestDisasm(t *testing.T) { func TestDisasm(t *testing.T) {
switch runtime.GOARCH { switch runtime.GOARCH {
case "arm64":
t.Skipf("skipping on %s, issue 10106", runtime.GOARCH)
case "mips", "mipsle", "mips64", "mips64le": case "mips", "mipsle", "mips64", "mips64le":
t.Skipf("skipping on %s, issue 12559", runtime.GOARCH) t.Skipf("skipping on %s, issue 12559", runtime.GOARCH)
case "s390x": case "s390x":
@ -167,8 +165,6 @@ func TestDisasm(t *testing.T) {
func TestDisasmCode(t *testing.T) { func TestDisasmCode(t *testing.T) {
switch runtime.GOARCH { switch runtime.GOARCH {
case "arm64":
t.Skipf("skipping on %s, issue 10106", runtime.GOARCH)
case "mips", "mipsle", "mips64", "mips64le": case "mips", "mipsle", "mips64", "mips64le":
t.Skipf("skipping on %s, issue 12559", runtime.GOARCH) t.Skipf("skipping on %s, issue 12559", runtime.GOARCH)
case "s390x": case "s390x":
@ -185,8 +181,6 @@ func TestDisasmExtld(t *testing.T) {
switch runtime.GOARCH { switch runtime.GOARCH {
case "ppc64": case "ppc64":
t.Skipf("skipping on %s, no support for external linking, issue 9038", runtime.GOARCH) 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": case "mips64", "mips64le", "mips", "mipsle":
t.Skipf("skipping on %s, issue 12559 and 12560", runtime.GOARCH) t.Skipf("skipping on %s, issue 12559 and 12560", runtime.GOARCH)
case "s390x": case "s390x":
@ -206,8 +200,6 @@ func TestDisasmGoobj(t *testing.T) {
switch runtime.GOARCH { switch runtime.GOARCH {
case "arm": case "arm":
t.Skipf("skipping on %s, issue 19811", runtime.GOARCH) 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": case "mips", "mipsle", "mips64", "mips64le":
t.Skipf("skipping on %s, issue 12559", runtime.GOARCH) t.Skipf("skipping on %s, issue 12559", runtime.GOARCH)
case "s390x": case "s390x":