Skip to content

Instantly share code, notes, and snippets.

@fwhacking
Created February 17, 2011 16:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fwhacking/832028 to your computer and use it in GitHub Desktop.
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
#!/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