Last active
July 10, 2018 19:02
-
-
Save ahhh/11e395384e2c8a940573341ab4d49871 to your computer and use it in GitHub Desktop.
colorized go-objdump
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 | |
go tool objdump -S "$@" | | |
gsed -E 's/^ ([^\t]+)(.*)/\1 \2/' | | |
sed -E "s,^(TEXT )([^ ]+)(.*),$(tput setaf 3)\\1$(tput bold)\\2$(tput sgr0)$(tput setaf 3)\\3$(tput sgr0)," | | |
gsed -E 's/((JMP|RET|UD2).*)$/\1\n/' | | |
sed -E "s,.*(CALL |RET).*,$(tput setaf 2)&$(tput sgr0)," | | |
sed -E "s,.*UD2.*,$(tput setaf 1)&$(tput sgr0)," | | |
sed -E "s,.*J[A-Z]+.*,$(tput setaf 4)&$(tput sgr0)," | | |
sed -E "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