mirror of
https://github.com/notwa/rc
synced 2024-11-05 04:39:03 -08:00
18 lines
668 B
Bash
Executable file
18 lines
668 B
Bash
Executable file
#!/usr/bin/env sh
|
|
# disassembles a function given its symbolic name.
|
|
# YES_ZSH
|
|
# YES_BASH
|
|
# YES_DASH
|
|
|
|
# TODO: actually test that this works with dash.
|
|
|
|
function disf() { ### @-
|
|
### disassemble a single function from an unstripped executable, unreliably.
|
|
[ $# -le 2 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
|
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'
|
|
}
|
|
|
|
[ "${SOURCING:-0}" -gt 0 ] || disf "$@"
|