Description
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:
TEXT main.main(SB) /home/boger/gotests/hello.go
func main() {
0x98e50 e87e0010 MOVD 16(R30),R3 // ld r3,16(r30)
0x98e54 7c230840 CMPU R3,R1 // cmpld r3,r1
0x98e58 41800010 BLT 0x98e68 // blt 0x98e68
0x98e5c 7ca802a6 MOVD LR,R5 // mflr r5
0x98e60 4bfc8d81 CALL runtime.morestack_noctxt(SB) // bl 0x61be0
0x98e64 4bffffec BR main.main(SB) // b 0x98e50
0x98e68 7fe802a6 MOVD LR,R31 // mflr r31
0x98e6c fbe1ff91 MOVDU R31,-112(R1) // stdu r31,-112(r1)
fmt.Printf("Hello\n")
0x98e70 3fe00017 ADDIS $0,$23,R31 // lis r31,23
0x98e74 e87f4018 MOVD 16408(R31),R3 // ld r3,16408(r31)
return Fprintf(os.Stdout, format, a...)
0x98e78 3fe0000f ADDIS $0,$15,R31 // lis r31,15
0x98e7c 389fd580 ADD R31,$-10880,R4 // addi r4,r31,-10880
0x98e80 f8810020 MOVD R4,32(R1) // std r4,32(r1)
0x98e84 f8610028 MOVD R3,40(R1) // std r3,40(r1)
0x98e88 3fe0000d ADDIS $0,$13,R31 // lis r31,13
0x98e8c 387f2e5a ADD R31,$11866,R3 // addi r3,r31,11866
0x98e90 f8610030 MOVD R3,48(R1) // std r3,48(r1)
0x98e94 38600006 MOVD $6,R3 // li r3,6
0x98e98 f8610038 MOVD R3,56(R1) // std r3,56(r1)
0x98e9c f8010040 MOVD R0,64(R1) // std r0,64(r1)
0x98ea0 f8010048 MOVD R0,72(R1) // std r0,72(r1)
0x98ea4 f8010050 MOVD R0,80(R1) // std r0,80(r1)
0x98ea8 4bff8849 CALL fmt.Fprintf(SB) // bl 0x916f0
0x98eac ebe10000 MOVD 0(R1),R31 // ld r31,0(r1)
0x98eb0 7fe803a6 MOVD R31,LR // mtlr r31
0x98eb4 38210070 ADD R1,$112,R1 // addi r1,r1,112
0x98eb8 4e800020 RET // bclr 20,lt,0