Skip to content

Instantly share code, notes, and snippets.

@matthijskooijman
Created April 14, 2014 08:52
Show Gist options
  • Save matthijskooijman/10629220 to your computer and use it in GitHub Desktop.
Save matthijskooijman/10629220 to your computer and use it in GitHub Desktop.
avr-objdump -t output diff script
#!/bin/bash
# Diff avr-objdump -t output.
# Compares the presence and size of any non-debug symbols in the given
# section (or all sections if none given).
if [ "$#" = 3 ]; then
SECTION=$1
shift;
else
SECTION='[^ ]*'
fi
if [ "$#" != 2 ]; then
echo "Usage: $0 [section] file1 file2"
exit 1
fi
filter() {
# Drop anything but the request section
grep -E "^[0-9a-f]+ ....... $SECTION " |
# Drop debugging symbols
grep -Ev '^[0-9a-f]+ .....d. ' |
# Strip the address and flags, but keep the section, size and
# symbol name. Make them separated by tabs, so awk can split on
# that (without also splitting on any spaces inside the symbol
# name).
sed -r 's/^[0-9a-f]+ ....... ([^ ]*) ([0-9a-f]+) (.*)$/\1 \2 \3/' |
# Shuffle the order of fields (for sorting and easy reading)
awk -F'\t' '{ printf("%60s %s %s\n", $3, $2, $1); }' |
sort
}
grc diff <(cat $1 | filter) <(cat $2 | filter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment