Last active
September 1, 2021 02:06
-
-
Save Yamakaky/5faec1bba60e129c6960cd3c946057f4 to your computer and use it in GitHub Desktop.
Script to unmangle Rust symbols
This file contains 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
#!/usr/bin/sed -rf | |
# Unmangle Rust symbols | |
# See https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=cae15db74999edb96dd9f5bbd4d55849391dd92b | |
# Example, with [FlameGraph](https://github.com/brendangregg/FlameGraph): | |
# perf record -g target/debug/bin | |
# perf script | stackcollapse-perf | rust-unmangle | flamegraph > perf.svg | |
# Remove hash and address offset | |
s/::h[0-9a-f]{16}//g | |
s/\+0x[0-9a-f]+//g | |
# Convert special characters | |
s/\$C\$/,/g | |
s/\$SP\$/@/g | |
s/\$BP\$/*/g | |
s/\$RF\$/\&/g | |
s/\$LT\$/</g | |
s/\$GT\$/>/g | |
s/\$LP\$/(/g | |
s/\$RP\$/)/g | |
s/\$u20\$/ /g | |
s/\$u27\$/'/g | |
s/\$u5b\$/[/g | |
s/\$u5d\$/]/g | |
s/\$u7b\$/{/g | |
s/\$u7d\$/}/g | |
s/\$u7e\$/~/g | |
# Fix . and _ | |
s/\.\./::/g | |
s/[^\.]\.[^\.]/./g | |
s/([;:])_/\1/g |
Could I know a way of using this script? I have output of all the functions of a library saved in a text file currently, Is there any way that I could use this tool to unmangle the symbols.
It's in the header of the file. Just chmod +x and it should be fine.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moved to https://github.com/Yamakaky/rust-unmangle