-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdis.sh
More file actions
executable file
·40 lines (37 loc) · 1.49 KB
/
Copy pathdis.sh
File metadata and controls
executable file
·40 lines (37 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/zsh
# Disassemble hyperd by symbol name, or dump the symbol table.
#
# Only the macOS arm64 build carries symbols; the Linux hyperd is fully
# stripped. See README.md §6.
#
# ./dis.sh syms write demangled hyper:: symbols to syms.txt
# ./dis.sh grep RootRecord search the demangled names
# ./dis.sh __ZNK5hyper10RootRecord15computeChecksumEv disassemble one symbol
# (note the K in __ZNK for const methods; `./dis.sh grep` gives you the
# demangled name, `./dis.sh grep -- -mangled` is not a thing - look the
# address up in syms.txt and use `at` if the mangling is fighting you)
# ./dis.sh at 0x104cc7ad4 0x104cc7bcc disassemble an address range
set -e
HERE=${0:a:h}
BIN=$HERE/bin/hyper/tableauhyperapi-0.0.25080-py3-none-macosx_13_0_arm64/tableauhyperapi/bin/hyper/hyperd
SYMS=$HERE/syms.txt
LLVM=$(xcrun -f llvm-objdump)
[[ -f $BIN ]] || { print -u2 "missing $BIN - unpack the macosx_13_0_arm64 wheel"; exit 1 }
case $1 in
syms)
nm -a $BIN | awk '{print $1" "$NF}' | grep '_ZN5hyper\|_ZNK5hyper' > /tmp/hyper.raw
paste -d' ' <(cut -d' ' -f1 /tmp/hyper.raw) \
<(cut -d' ' -f2 /tmp/hyper.raw | c++filt) > $SYMS
print "$(wc -l < $SYMS) symbols -> $SYMS"
;;
grep)
[[ -f $SYMS ]] || $0 syms
grep -i "$2" $SYMS
;;
at)
$LLVM -d --start-address=$2 --stop-address=$3 $BIN
;;
*)
$LLVM -d --disassemble-symbols="$1" $BIN | grep -v '^hyperd:\|file format\|^Disassembly\|^$'
;;
esac