【汇编实践】go assembly
https://mp.weixin.qq.com/s/B577CdUkWCp_XgUc1VVvSQ
asmshare/layout.md at master · cch123/asmshare https://github.com/cch123/asmshare/blob/master/layout.md
package main func main() { var sli = make([]int, 0, 10) f(sli) } func f(sli []int) { sli = append(sli, 1) } go tool compile -S main.go "".main STEXT nosplit size=1 args=0x0 locals=0x0 funcid=0x0 align=0x0 0x0000 00000 (main.go:3) TEXT "".main(SB), NOSPLIT|ABIInternal, $0-0 0x0000 00000 (main.go:3) FUNCDATA $0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) 0x0000 00000 (main.go:3) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) 0x0000 00000 (main.go:6) RET 0x0000 c3 . "".f STEXT size=123 args=0x18 locals=0x48 funcid=0x0 align=0x0 0x0000 00000 (main.go:8) TEXT "".f(SB), ABIInternal, $72-24 0x0000 00000 (main.go:8) CMPQ SP, 16(R14) 0x0004 00004 (main.go:8) PCDATA $0, $-2 0x0004 00004 (main.go:8) JLS 86 0x0006 00006 (main.go:8) PCDATA $0, $-1 0x0006 00006 (main.go:8) SUBQ $72, SP 0x000a 00010 (main.go:8) MOVQ BP, 64(SP) 0x000f 00015 (main.go:8) LEAQ 64(SP), BP 0x0014 00020 (main.go:8) MOVQ AX, "".sli+80(FP) 0x0019 00025 (main.go:8) FUNCDATA $0, gclocals·1a65e721a2ccc325b382662e7ffee780(SB) 0x0019 00025 (main.go:8) FUNCDATA $1, gclocals·69c1753bd5f81501d95132d08af04464(SB) 0x0019 00025 (main.go:8) FUNCDATA $5, "".f.arginfo1(SB) 0x0019 00025 (main.go:8) FUNCDATA $6, "".f.argliveinfo(SB) 0x0019 00025 (main.go:8) PCDATA $3, $1 0x0019 00025 (main.go:9) LEAQ 1(BX), SI 0x001d 00029 (main.go:9) NOP 0x0020 00032 (main.go:9) CMPQ CX, SI 0x0023 00035 (main.go:9) JCC 68 0x0025 00037 (main.go:9) MOVQ BX, "".sli+88(SP) 0x002a 00042 (main.go:9) PCDATA $3, $2 0x002a 00042 (main.go:9) MOVQ CX, DI 0x002d 00045 (main.go:9) MOVQ BX, CX 0x0030 00048 (main.go:9) MOVQ AX, BX 0x0033 00051 (main.go:9) LEAQ type.int(SB), AX 0x003a 00058 (main.go:9) PCDATA $1, $0 0x003a 00058 (main.go:9) CALL runtime.growslice(SB) 0x003f 00063 (main.go:9) MOVQ "".sli+88(SP), BX 0x0044 00068 (main.go:9) PCDATA $1, $-1 0x0044 00068 (main.go:9) PCDATA $3, $1 0x0044 00068 (main.go:9) MOVQ $1, (AX)(BX*8) 0x004c 00076 (main.go:10) MOVQ 64(SP), BP 0x0051 00081 (main.go:10) ADDQ $72, SP 0x0055 00085 (main.go:10) RET 0x0056 00086 (main.go:10) NOP 0x0056 00086 (main.go:8) PCDATA $1, $-1 0x0056 00086 (main.go:8) PCDATA $0, $-2 0x0056 00086 (main.go:8) MOVQ AX, 8(SP) 0x005b 00091 (main.go:8) MOVQ BX, 16(SP) 0x0060 00096 (main.go:8) MOVQ CX, 24(SP) 0x0065 00101 (main.go:8) CALL runtime.morestack_noctxt(SB) 0x006a 00106 (main.go:8) MOVQ 8(SP), AX 0x006f 00111 (main.go:8) MOVQ 16(SP), BX 0x0074 00116 (main.go:8) MOVQ 24(SP), CX 0x0079 00121 (main.go:8) PCDATA $0, $-1 0x0079 00121 (main.go:8) JMP 0 0x0000 49 3b 66 10 76 50 48 83 ec 48 48 89 6c 24 40 48 I;f.vPH..HH.l$@H 0x0010 8d 6c 24 40 48 89 44 24 50 48 8d 73 01 0f 1f 00 .l$@H.D$PH.s.... 0x0020 48 39 f1 73 1f 48 89 5c 24 58 48 89 cf 48 89 d9 H9.s.H.\$XH..H.. 0x0030 48 89 c3 48 8d 05 00 00 00 00 e8 00 00 00 00 48 H..H...........H 0x0040 8b 5c 24 58 48 c7 04 d8 01 00 00 00 48 8b 6c 24 .\$XH.......H.l$ 0x0050 40 48 83 c4 48 c3 48 89 44 24 08 48 89 5c 24 10 @H..H.H.D$.H.\$. 0x0060 48 89 4c 24 18 e8 00 00 00 00 48 8b 44 24 08 48 H.L$......H.D$.H 0x0070 8b 5c 24 10 48 8b 4c 24 18 eb 85 .\$.H.L$... rel 54+4 t=14 type.int+0 rel 59+4 t=7 runtime.growslice+0 rel 102+4 t=7 runtime.morestack_noctxt+0 go.cuinfo.packagename. SDWARFCUINFO dupok size=0 0x0000 6d 61 69 6e main go.info."".f$abstract SDWARFABSFCN dupok size=17 0x0000 05 2e 66 00 01 01 13 73 6c 69 00 00 00 00 00 00 ..f....sli...... 0x0010 00 . rel 0+0 t=22 type.[]int+0 rel 12+4 t=31 go.info.[]int+0 ""..inittask SNOPTRDATA size=24 0x0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0x0010 00 00 00 00 00 00 00 00 ........ runtime.memequal64·f SRODATA dupok size=8 0x0000 00 00 00 00 00 00 00 00 ........ rel 0+8 t=1 runtime.memequal64+0 runtime.gcbits.01 SRODATA dupok size=1 0x0000 01 . type..namedata.*[]int- SRODATA dupok size=8 0x0000 00 06 2a 5b 5d 69 6e 74 ..*[]int type.*[]int SRODATA dupok size=56 0x0000 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................ 0x0010 1b 31 52 88 08 08 08 36 00 00 00 00 00 00 00 00 .1R....6........ 0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0x0030 00 00 00 00 00 00 00 00 ........ rel 24+8 t=1 runtime.memequal64·f+0 rel 32+8 t=1 runtime.gcbits.01+0 rel 40+4 t=5 type..namedata.*[]int-+0 rel 48+8 t=1 type.[]int+0 type.[]int SRODATA dupok size=56 0x0000 18 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................ 0x0010 8e 66 f9 1b 02 08 08 17 00 00 00 00 00 00 00 00 .f.............. 0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0x0030 00 00 00 00 00 00 00 00 ........ rel 32+8 t=1 runtime.gcbits.01+0 rel 40+4 t=5 type..namedata.*[]int-+0 rel 44+4 t=-32763 type.*[]int+0 rel 48+8 t=1 type.int+0 gclocals·33cdeccccebe80329f1fdbee7f5874cb SRODATA dupok size=8 0x0000 01 00 00 00 00 00 00 00 ........ gclocals·1a65e721a2ccc325b382662e7ffee780 SRODATA dupok size=10 0x0000 02 00 00 00 01 00 00 00 01 00 .......... gclocals·69c1753bd5f81501d95132d08af04464 SRODATA dupok size=8 0x0000 02 00 00 00 00 00 00 00 ........ "".f.arginfo1 SRODATA static dupok size=9 0x0000 fe 00 08 08 08 10 08 fd ff ......... "".f.argliveinfo SRODATA static dupok size=3 0x0000 00 00 02 ...