Forked from CAFxX/Colorized and formatted go tool objdump output.png
Created
July 9, 2020 18:07
-
-
Save junftnt/4a868b995ed4a9d213c39ccd05a41a29 to your computer and use it in GitHub Desktop.
Colorized and formatted go tool objdump output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # go-objdump colorizes and reformats output of `go tool objdump` | |
| # - it inserts an empty line after unconditional control-flow modifying instructions (JMP, RET, UD2) | |
| # - it colors calls/returns in green | |
| # - it colors traps (UD2) in red | |
| # - it colors jumps (both conditional and unconditional) in blue | |
| # - it colors padding/nops in violet | |
| # - it colors the function name in yellow | |
| # - it unindent the function body | |
| function go-objdump() { | |
| go tool objdump "$@" | | |
| gsed -E " | |
| s/^ ([^\t]+)(.*)/\1 \2/ | |
| s,^(TEXT )([^ ]+)(.*),$(tput setaf 3)\\1$(tput bold)\\2$(tput sgr0)$(tput setaf 3)\\3$(tput sgr0), | |
| s/((JMP|RET|UD2).*)\$/\1\n/ | |
| s,.*(CALL |RET).*,$(tput setaf 2)&$(tput sgr0), | |
| s,.*UD2.*,$(tput setaf 1)&$(tput sgr0), | |
| s,.*J[A-Z]+.*,$(tput setaf 4)&$(tput sgr0), | |
| s,.*(INT \\\$0x3|NOP).*,$(tput setaf 5)&$(tput sgr0), | |
| " | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
