Testing instruction set
Tavis Ormandy <[email protected]>
| Newsgroups | gmane.linux.gentoo.alpha |
|---|---|
| Message-ID | <[email protected]> |
We put this script together today in #gentoo-alpha, we needed a way to find out what instruction set a binary was compiled for to track down a bug, and this script helped. I think its really cool, so i thought id share it with you guys :) example output: $ ./analyse /usr/bin/less bwx: 663 mvi: 0 fix: 0 cix: 0 /usr/bin/less will run on ev56 and newer. #!/bin/sh # Tavis Ormandy <[email protected]> 2003 # Improvements by Will Woods <[email protected]> # # Guess what alpha revision a binary was compiled for # using objdump. # eval {bwx,fix,cix,mvi}=0 objdump -d $1 | cut -f3 | ( while read instruction; do print="" case "$instruction" in "ldbu"|"ldwu"|"sextb"|"sextw"|"stb"|"stw") let ++bwx; print=1 ;; "maxsb8"|"maxsw4"|"maxub8"|"maxuw4"|"minsb8"|"minsw4"|"minub8"|"minuw4"|"perr"|"pklb"|"pkwb"|"unpkbl"|"unpkbw") let ++mvi; print=1;; "ftois"|"ftoit"|"itoff"|"itofs"|"itoft"|"sqrtf"|"sqrtg"|"sqrts"|"sqrtt") let ++fix; print=1;; "ctlz"|"ctpop"|"cttz") let ++cix; print=1;; esac if [ -n "$print" ] ; then printf "bwx: %4u mvi: %4u fix:%4u cix: %4u\r" $bwx $mvi $fix $cix fi done echo if [ $cix -gt 0 ]; then subarch="ev67" ; elif [ $fix -gt 0 ]; then subarch="ev6" ; elif [ $mvi -gt 0 ]; then subarch="pca56" ; elif [ $bwx -gt 0 ]; then subarch="ev56" ; fi if [ -z "$subarch" ]; then echo "$1 will run on any alpha." else echo "$1 will run on $subarch and newer." fi ) -- ------------------------------------- [email protected] | finger me for my gpg key. ------------------------------------------------------- -- [email protected] mailing list