Denys Vlasenko | adf922e | 2009-10-08 14:35:37 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Denys Vlasenko | 02788ac | 2010-10-28 20:45:37 +0200 | [diff] [blame] | 3 | usage() { |
| 4 | echo "Usage: ${0##*/} DIR1 DIR2" |
| 5 | echo |
| 6 | echo "Compares all object files recursivelty found in DIR1 and DIR2." |
| 7 | echo "Prints diff of their disassembly." |
| 8 | echo |
| 9 | exit $1 |
| 10 | } |
| 11 | |
Denys Vlasenko | adf922e | 2009-10-08 14:35:37 +0200 | [diff] [blame] | 12 | filter() { |
| 13 | # sed removes " address: " prefixes which mess up diff |
| 14 | sed $'s/^\\(\t*\\)[ ]*[0-9a-f][0-9a-f]*:[ \t]*/\\1/' \ |
| 15 | | sed 's/__GI_//g' |
| 16 | } |
| 17 | |
Denys Vlasenko | 02788ac | 2010-10-28 20:45:37 +0200 | [diff] [blame] | 18 | test -d "$1" || usage 1 |
| 19 | test -d "$2" || usage 1 |
Denys Vlasenko | adf922e | 2009-10-08 14:35:37 +0200 | [diff] [blame] | 20 | |
| 21 | { |
| 22 | ( |
| 23 | cd "$1" || exit 1 |
Denys Vlasenko | 02788ac | 2010-10-28 20:45:37 +0200 | [diff] [blame] | 24 | find -name '*.o' # -o -name '*.os' # -o -name '*.so' |
Denys Vlasenko | adf922e | 2009-10-08 14:35:37 +0200 | [diff] [blame] | 25 | ) |
| 26 | ( |
| 27 | cd "$2" || exit 1 |
Denys Vlasenko | 02788ac | 2010-10-28 20:45:37 +0200 | [diff] [blame] | 28 | find -name '*.o' # -o -name '*.os' # -o -name '*.so' |
Denys Vlasenko | adf922e | 2009-10-08 14:35:37 +0200 | [diff] [blame] | 29 | ) |
| 30 | } | sed 's:^\./::' | sort | uniq | \ |
Denys Vlasenko | adf922e | 2009-10-08 14:35:37 +0200 | [diff] [blame] | 31 | ( |
Denys Vlasenko | 02788ac | 2010-10-28 20:45:37 +0200 | [diff] [blame] | 32 | while IFS='' read -r oname; do |
Denys Vlasenko | adf922e | 2009-10-08 14:35:37 +0200 | [diff] [blame] | 33 | if ! test -f "$1/$oname"; then |
| 34 | echo "Only $2/$oname" |
| 35 | continue |
| 36 | fi |
| 37 | if ! test -f "$2/$oname"; then |
| 38 | echo "Only $1/$oname" |
| 39 | continue |
| 40 | fi |
| 41 | diff -q -- "$1/$oname" "$2/$oname" >/dev/null && continue |
Denys Vlasenko | 1642d02 | 2010-10-29 19:06:20 +0200 | [diff] [blame] | 42 | (cd "$1" && { size "$oname"; objdump -dr "$oname" | filter; } >"$oname.disasm") |
| 43 | (cd "$2" && { size "$oname"; objdump -dr "$oname" | filter; } >"$oname.disasm") |
Denys Vlasenko | 02788ac | 2010-10-28 20:45:37 +0200 | [diff] [blame] | 44 | diff -u -- "$1/$oname.disasm" "$2/$oname.disasm" |
Denys Vlasenko | adf922e | 2009-10-08 14:35:37 +0200 | [diff] [blame] | 45 | done |
| 46 | ) |