2021-07-29 05:44:12 -07:00
|
|
|
#!/usr/bin/env sh
|
2017-10-01 21:17:32 -07:00
|
|
|
# disassembles a function given its symbolic name.
|
2021-07-29 00:37:35 -07:00
|
|
|
# YES_ZSH
|
2021-07-29 05:44:12 -07:00
|
|
|
# YES_BASH
|
|
|
|
|
2021-09-23 06:48:05 -07:00
|
|
|
# does not work with busybox sed (yet?)
|
2021-07-29 00:37:35 -07:00
|
|
|
|
2021-08-02 13:48:46 -07:00
|
|
|
disf() { ### @-
|
2021-07-30 17:57:08 -07:00
|
|
|
### disassemble a single function from an unstripped executable, unreliably.
|
2021-07-29 00:37:35 -07:00
|
|
|
[ $# -le 2 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
2017-10-01 21:17:32 -07:00
|
|
|
local exe="${1:?first argument should be an unstripped executable}"
|
|
|
|
local symbol="${2:?second argument should be a function name}"
|
|
|
|
# note: relies on GNU sed: https://unix.stackexchange.com/a/78485
|
|
|
|
objdump -d -C --no-show-raw-insn "$exe" | sed '/<'"$symbol"'>:/,/^$/!d;//d'
|
|
|
|
}
|
2021-07-29 00:37:35 -07:00
|
|
|
|
2021-08-02 13:48:46 -07:00
|
|
|
[ -n "${preload+-}" ] || disf "$@"
|