Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # SPDX-License-Identifier: GPL-2.0
0003 #
0004 # Disassemble a single function.
0005 #
0006 # usage: objdump-func <file> <func>
0007 
0008 set -o errexit
0009 set -o nounset
0010 
0011 OBJDUMP="${CROSS_COMPILE:-}objdump"
0012 
0013 command -v gawk >/dev/null 2>&1 || die "gawk isn't installed"
0014 
0015 usage() {
0016         echo "usage: objdump-func <file> <func>" >&2
0017         exit 1
0018 }
0019 
0020 [[ $# -lt 2 ]] && usage
0021 
0022 OBJ=$1; shift
0023 FUNC=$1; shift
0024 
0025 # Secret feature to allow adding extra objdump args at the end
0026 EXTRA_ARGS=$@
0027 
0028 # Note this also matches compiler-added suffixes like ".cold", etc
0029 ${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; } }'