Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/objdump: add -gnu flag to use GNU/AT&T syntax in disassembly #34372
I have had a patch to do this for quite a while on ppc64 which I've provided to internal and external developers who want to write Go assembler to optimize their code. I tried to sneak it in a while back for ppc64 but Cherry suggested I make it a proposal.
The initial goal was to make it easier for Go developers who write Go assembler to verify they are getting the native assembler they expect. Many are experts in their native assembler but not in Go assembler. With this change, the Go objdump will show both side by side. This is also helpful for any code compiled with Golang. The gnu objdump can be used to disassemble Go binaries but not all objects created by Go are accepted.
This could be controlled by option but that is probably too much bother, unless there are concerns about doing this all the time.
It can be added easily for ppc64 and others assuming GNUSyntax works well. I tried it for x86 but since I'm not fluent there I can't verify if the output looks like it should.
Here is an example of the output:
This adds support for the -gnu option on Go objdump. When this option is used, then output will include gnu assembly in comments alongside the Go assembly. The objdump test was updated to test this new option. This option is supported for the arches found in golang.org/x that provide the GNUsyntax function. Updates #34372 Change-Id: I9e60e1691526607dda3c857c4564dcef408b8391 Reviewed-on: https://go-review.googlesource.com/c/go/+/225459 Run-TryBot: Lynn Boger <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Cherry Zhang <email@example.com>