#trim #go #assembly #compile #tool

app trim-go-asm

Trim Go Assembly from $ go tool compile -S

3 releases

0.1.3 Feb 25, 2022
0.1.1 Feb 25, 2022
0.1.0 Oct 30, 2021

#16 in #trim

MIT license

15KB
405 lines

Contains (ar library, 3KB) x.o

trim-go-asm

Trim Go Assembly from $ go tool compile -S

Install

$ cargo install trim-go-asm

How to use

Version 0.1 can parse input only from stdin. So, $ go tool compile -S x.go > trim-go-asm is the most likely use case.

Contributing

Any contributions are welcome!

TODOs

  • Read from file by option.
  • Accept *.go by option, then run go tool compile -S <filename>.go | trim-go-asm > <filename>.s
  • Specify the output path by -o
  • THIS IS FOR ME Add subcommand for-me
USAGE:
    trim-go-asm [OPTIONS]

OPTIONS:
        --fm         todo!
    -h, --help       Print help information
        --ra         Replace `ABIInternal` to 4(NOSPLIT)
        --rpf        Remove PCDATA and FUNCDATA insts, if you want to enable this option, you must
                     enable --tg too.
        --tg         Trim Goroutine prologue / epilogue
                     // Trim these instructions.
                     MOVQ       (TLS), CX
                     CMPQ       SP, 16(CX)
                     PCDATA     $0, $-2
                     JLS        70
                     PCDATA     $0, $-1
                     // ...
                     NOP
                     PCDATA     $1, $-1
                     PCDATA     $0, $-2
                     CALL       runtime.morestack_noctxt(SB)
                     PCDATA     $0, $-1
                     JMP        0
    -V, --version    Print version information

Dependencies

~1.5MB
~24K SLoC