Skip to content

Instantly share code, notes, and snippets.

@faywong
Created October 23, 2024 06:54
Show Gist options
  • Save faywong/aa678ad6357f7649ff38425a0631984d to your computer and use it in GitHub Desktop.
Save faywong/aa678ad6357f7649ff38425a0631984d to your computer and use it in GitHub Desktop.
反汇编一个函数
#!/bin/sh
#file: /usr/bin/dis
#disassemble a function
#author: sid
export PATH=/Users/faywong/Library/Android/sdk/ndk/21.1.6352462/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin:$PATH
routine=$1
func=$2
if [ -z "$routine" ]; then
exit
fi
start=$(aarch64-linux-android-nm -n $routine | grep "\w\s$func" | awk '{print "0x"$1;exit}')
end=$(aarch64-linux-android-nm -n $routine | grep -A1 "\w\s$func" | awk '{getline; print "0x"$1;exit}')
if [ -z "$func" ]; then
aarch64-linux-android-objdump -d $routine
else
echo "start-address: $start, end-address: $end"
aarch64-linux-android-objdump -d $routine --start-address=$start --stop-address=$end
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment