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