Commit c195deb4 authored by Wei Xiao's avatar Wei Xiao Committed by Cherry Zhang

cmd/internal/objfile: add arm64 disassembler support

Fixes #19157

Change-Id: Ieea286e8dc03929c3645f3113c33df569f8e26f3
Reviewed-on: https://go-review.googlesource.com/58930Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
parent 5d39af9d
......@@ -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,
......
......@@ -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"
......
......@@ -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":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment