Skip to content

Instantly share code, notes, and snippets.

@CoRfr
Last active March 12, 2018 23:20
Show Gist options
  • Select an option

  • Save CoRfr/11718a4a2cc2079c52ca45eceb34da82 to your computer and use it in GitHub Desktop.

Select an option

Save CoRfr/11718a4a2cc2079c52ca45eceb34da82 to your computer and use it in GitHub Desktop.
cmp-so
#!/bin/bash -e
if [ -z "$OBJDUMP" ]; then
OBJDUMP="$(which objdump)"
echo "Using $OBJDUMP"
fi
LEFT=$1
RIGHT=$2
if [ -z "$LEFT" ] || [ -z "$RIGHT" ]; then
exit 1
fi
echo "Comparing $LEFT vs $RIGHT"
cmp_so() {
# Left
cd $(dirname $LEFT)
$OBJDUMP $* $(basename $LEFT) | tail +3 > "/tmp/cmp.left"
# Right
cd $(dirname $RIGHT)
$OBJDUMP $* $(basename $RIGHT) | tail +3 > "/tmp/cmp.right"
diff "/tmp/cmp.left" "/tmp/cmp.right"
}
cmp_hexdump() {
# Left
cd $(dirname $LEFT)
hexdump -C $(basename $LEFT) > "/tmp/cmp.left"
# Right
cd $(dirname $RIGHT)
hexdump -C $(basename $RIGHT) > "/tmp/cmp.right"
diff "/tmp/cmp.left" "/tmp/cmp.right"
}
echo "-> All sections"
cmp_so -D
echo "-> Symbol table"
cmp_so -t
echo "-> Dynamic symbol table"
cmp_so -T
echo "-> Hexdump"
cmp_hexdump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment