summaryrefslogtreecommitdiff
path: root/scripts/objdump-func
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2022-07-08 23:39:28 +0300
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2022-07-08 23:39:28 +0300
commita63f7778f76e1cf8ed3bcb7a1d9453c9609121ad (patch)
tree9a26f3ff67dfbd542c6eca3e5c1c7f443b1647dd /scripts/objdump-func
parentc4bcc1b99b8b8acdfe673e4701a9c2acb6b8b2fb (diff)
parent88084a3df1672e131ddc1b4e39eeacfd39864acf (diff)
downloadlinux-a63f7778f76e1cf8ed3bcb7a1d9453c9609121ad.tar.xz
Merge tag 'v5.19-rc5' into next
Merge with mainline to bring up the latest definition from MFD subsystem needed for Mediatek keypad driver.
Diffstat (limited to 'scripts/objdump-func')
-rwxr-xr-xscripts/objdump-func29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/objdump-func b/scripts/objdump-func
new file mode 100755
index 000000000000..4eb463dd9f52
--- /dev/null
+++ b/scripts/objdump-func
@@ -0,0 +1,29 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Disassemble a single function.
+#
+# usage: objdump-func <file> <func>
+
+set -o errexit
+set -o nounset
+
+OBJDUMP="${CROSS_COMPILE:-}objdump"
+
+command -v gawk >/dev/null 2>&1 || die "gawk isn't installed"
+
+usage() {
+ echo "usage: objdump-func <file> <func>" >&2
+ exit 1
+}
+
+[[ $# -lt 2 ]] && usage
+
+OBJ=$1; shift
+FUNC=$1; shift
+
+# Secret feature to allow adding extra objdump args at the end
+EXTRA_ARGS=$@
+
+# Note this also matches compiler-added suffixes like ".cold", etc
+${OBJDUMP} -wdr $EXTRA_ARGS $OBJ | gawk -M -v f=$FUNC '/^$/ { P=0; } $0 ~ "<" f "(\\..*)?>:" { P=1; O=strtonum("0x" $1); } { if (P) { o=strtonum("0x" $1); printf("%04x ", o-O); print $0; } }'