what does 'go.info,go.range' mean in golang asm?

58 views
Skip to first unread message

sheepbao

unread,
Jan 18, 2018, 9:21:14 PM1/18/18
to golang-nuts
I wrote this code add.go:
package asm

func add(a, b int) int {
   return a + b
}

then I compile this code to asm:
go tool compile -S add.go
the output is:
"".add STEXT nosplit size=19 args=0x18 locals=0x0
   0x0000 00000 (add.go:3) TEXT    "".add(SB), NOSPLIT, $0-24
   0x0000 00000 (add.go:3) FUNCDATA    $0, gclocals·54241e171da8af6ae173d69da0236748(SB)
   0x0000 00000 (add.go:3) FUNCDATA    $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
   0x0000 00000 (add.go:3) MOVQ    "".b+16(SP), AX
   0x0005 00005 (add.go:3) MOVQ    "".a+8(SP), CX
   0x000a 00010 (add.go:4) ADDQ    CX, AX
   0x000d 00013 (add.go:4) MOVQ    AX, "".~r2+24(SP)
   0x0012 00018 (add.go:4) RET
   0x0000 48 8b 44 24 10 48 8b 4c 24 08 48 01 c8 48 89 44  H.D$.H.L$.H..H.D
   0x0010 24 18 c3                                         $..
go.info."".add SDWARFINFO size=63
   0x0000 02 22 22 2e 61 64 64 00 00 00 00 00 00 00 00 00  ."".add.........
   0x0010 00 00 00 00 00 00 00 00 01 9c 01 05 61 00 01 9c  ............a...
   0x0020 00 00 00 00 05 62 00 04 9c 11 08 22 00 00 00 00  .....b....."....
   0x0030 05 7e 72 32 00 04 9c 11 10 22 00 00 00 00 00     .~r2.....".....
   rel 8+8 t=1 "".add+0
   rel 16+8 t=1 "".add+19
   rel 32+4 t=28 go.info.int+0
   rel 44+4 t=28 go.info.int+0
   rel 58+4 t=28 go.info.int+0
go.range."".add SDWARFRANGE size=0
gclocals·54241e171da8af6ae173d69da0236748 SRODATA dupok size=9
   0x0000 01 00 00 00 03 00 00 00 00                       .........
gclocals·33cdeccccebe80329f1fdbee7f5874cb SRODATA dupok size=8
   0x0000 01 00 00 00 00 00 00 00                          ........


what does 'go.info,go.range' mean in this asm? how can I found info about this? I had see the doc, but not I wanted. https://golang.org/doc/asm

Ian Lance Taylor

unread,
Jan 18, 2018, 10:43:09 PM1/18/18
to sheepbao, golang-nuts
The output of the compiler's -S option is unfortunately not suitable
as input for the assembler.

go.info and go.range are symbol names, although the way the compiler
works they could also be thought of section names.

Ian
Reply all
Reply to author
Forward
0 new messages