Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/objdump: can not disassemble ARM DIVUHW / DIVHW #20096

Closed
benshi001 opened this issue Apr 24, 2017 · 12 comments
Closed

cmd/objdump: can not disassemble ARM DIVUHW / DIVHW #20096

benshi001 opened this issue Apr 24, 2017 · 12 comments
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@benshi001
Copy link
Member

benshi001 commented Apr 24, 2017

Wtih a simple test file arm.s
TEXT foo(SB), 4, $0
DIVHW R0, R1, R2
DIVUHW R0, R1, R2
DIVHW R0, R1
DIVUHW R0, R1
ADD $ 0xfff9, R0
END

Here are what I do and the results,
pi@raspberrypi:~ $ cat arm.s
TEXT foo(SB), 4, $0
DIVHW R0, R1, R2
DIVUHW R0, R1, R2
DIVHW R0, R1
DIVUHW R0, R1
ADD $ 0xfff9, R0
END
pi@raspberrypi:~ $ GOROOT= ~ /go PATH=$GOROOT/bin:$PATH go tool asm arm.s
pi@raspberrypi:~ $ GOROOT= ~ /go PATH=$GOROOT/bin:$PATH go tool objdump arm.o
TEXT foo(SB) gofile../home/pi/arm.s
arm.s:4 0x85 e712f011 ?
arm.s:5 0x89 e732f011 ?
arm.s:7 0x8d e711f011 ?
arm.s:8 0x91 e731f011 ?
arm.s:10 0x95 e30fbff9 MOVW $65529, R11
arm.s:10 0x99 e080000b ADD R11, R0, R0

The DIVHW/DIVUHW are not disassembled .

@bradfitz bradfitz changed the title src/cmd/objdump: can not disassemble DIVUHW / DIVHW cmd/objdump: can not disassemble DIVUHW / DIVHW Apr 24, 2017
@bradfitz bradfitz changed the title cmd/objdump: can not disassemble DIVUHW / DIVHW cmd/objdump: can not disassemble ARM DIVUHW / DIVHW Apr 24, 2017
@bradfitz bradfitz added this to the Go1.9Maybe milestone Apr 24, 2017
@bradfitz bradfitz added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Apr 24, 2017
@cherrymui
Copy link
Member

The disassembler comes from x/arch subrepo (https://go.googlesource.com/arch), which contains a table generated by parsing the PDF of the hardware manual. It looks like these instructions are not in the table.

@benshi001 would you like to update the table with a newer version of the manual that includes these instructions? (I don't have one.)

@benshi001
Copy link
Member Author

OK. I will do it later. Thank you.

@benshi001
Copy link
Member Author

Questions,

  1. https://github.com/golang/go/tree/master/src/cmd/vendor/golang.org/x/arch/arm/armasm is much older than https://github.com/golang/arch/tree/master/, which one should I follow?
  2. Which tool is used to generate arm.csv? Or I have to edit it by hand?
  3. Any more instructions ?

@benshi001
Copy link
Member Author

arm.csv.zip

  1. I checked the newest arm manual against the arm.csv, UDIV/SDIV/UDF are new added, and others are not used by go. (Such as VCLZ is SIMD, CHKA is ThumbEE)

  2. I added UDIV/SDIV/UDF to the attached arm.csv and got tables.go by "go run ../armmap/map.go -fmt=decoder ../arm.csv >_tables.go && gofmt _tables.go >tables.go && rm _tables.go".

  3. I committed https://go-review.googlesource.com/c/41890/, now DIVHW and DIVUHW can be disassembled correctly.

// DIVHW R0, R1, R2: R1 / R0 -> R2
DIVHW R0, R1, R2 // 11f012e7
DIVUHW R0, R1, R2 // 11f032e7
// DIVHW R0, R1: R1 / R0 -> R1
DIVHW R0, R1 // 11f011e7
DIVUHW R0, R1 // 11f031e7

arm.s:8 0x8f e712f011 SDIV R0, R1, R2
arm.s:9 0x93 e732f011 UDIV R0, R1, R2
arm.s:11 0x97 e711f011 SDIV R0, R1, R1
arm.s:12 0x9b e731f011 UDIV R0, R1, R1

@benshi001
Copy link
Member Author

The UDF is not supported by the assembler, so it is not tested.

@benshi001
Copy link
Member Author

A bug is found,

"MULS R1, R2, R3, R4" is dissambled to "MLS R3, R1, R2, R4", which should be "MLS R1, R2, R3, R4"

Patch set 3 of CL https://go-review.googlesource.com/#/c/41891/ fixes it.

@gopherbot
Copy link

CL https://golang.org/cl/42171 mentions this issue.

@benshi001
Copy link
Member Author

https://go-review.googlesource.com/#/c/41891/ fixes the DIV/DIVU issue.
https://go-review.googlesource.com/#/c/42171/ fixes the MLA issue.

@benshi001
Copy link
Member Author

QADD is also not decoded correctly.

0xe1086055 should be decoded to "QADD R6, R8, R5" in GNU syntax, but actually "QADD R6, R5, R8".

@benshi001
Copy link
Member Author

There same error of wrong register list also exists in QDADD/QSUB

@benshi001
Copy link
Member Author

@gopherbot
Copy link

Change https://golang.org/cl/49530 mentions this issue: cmd/vendor/golang.org/x/arch: pull updates from x repo

gopherbot pushed a commit that referenced this issue Aug 16, 2017
Vendor from golang.org/x/arch (commit f185940).

Implements #19157

Updates #12840
Updates #20762
Updates #20897
Updates #20096
Updates #20766
Updates #20752
Updates #20096
Updates #19142

Change-Id: Idefb8ba2c355dc07f3b9e8dcf5f00173256a0f0f
Reviewed-on: https://go-review.googlesource.com/49530
Reviewed-by: Cherry Zhang <cherryyz@google.com>
@golang golang locked and limited conversation to collaborators Jul 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants