Created
February 17, 2011 16:20
-
-
Save fwhacking/832028 to your computer and use it in GitHub Desktop.
Print the sections of a binary (offset, length, name) in a nice and compact way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Copyright (C) 2011 <fwhacking|gmail:com> | |
# | |
# This is free software, licensed under the GNU General Public License v2. | |
# See /LICENSE for more information. | |
# | |
OBJDUMP=$(which objdump) | |
AWK=$(which awk) | |
if [ -z $OBJDUMP ]; then | |
echo "Please install 'objdump'" | |
exit 1 | |
fi | |
if [ -z $AWK ]; then | |
echo "Please install 'awk'" | |
exit 1 | |
fi | |
if [ $# -lt 1 ]; then | |
echo "Usage: $0 file" | |
exit 1 | |
fi | |
$OBJDUMP -h $1 | $AWK 'BEGIN {print "OFFSET LENGTH SECTION"} /[ ]+[0-9]+/ {printf "0x%s 0x%s %s\n", $6, $3, $2}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment