public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] Script to test instruction set.
@ 2003-08-12 11:55 Tavis Ormandy
  2003-08-12 14:13 ` Norbert Kamenicky
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Tavis Ormandy @ 2003-08-12 11:55 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]

Hey, this is an x86 port of a script i wrote (with some help from
wwoods) to identify what processor an alpha binary would work on.

I think its pretty cool, and had some good feedback so im posting it
here :)

Example:

$ ./analyse-x86 /bin/ls
Checking vendor_id string...GenuineIntel
Disassembling /bin/ls, please wait...
i486:    0 i586:    0 ppro:   15 mmx:    0 sse:    8 sse2:    0
/bin/ls will run on Pentium III (pentium3) or higher processor.

-- 
-------------------------------------
taviso@sdf.lonestar.org | finger me for my gpg key.
-------------------------------------------------------

[-- Attachment #2: analyse-x86 --]
[-- Type: text/plain, Size: 7492 bytes --]

#!/bin/sh
# Tavis Ormandy <taviso@gentoo.org> 2003
# Improvments by Will Woods <wwoods@gentoo.org>
#
# Identify instruction set used in binary.
#

# initialize everything to zero.
eval {i486,i586,ppro,mmx,sse,sse2,amd,amd2,cpuid}=0

# unfortunately there are mnemonic collissions between vendor sets
# so check vendor_id string, and enable relevant sets.
printf "Checking vendor_id string..."
if ! test "${1%=*}" == "--vendor"; then
	case "`grep -Em1 '^vendor_id.*: ' /proc/cpuinfo | cut -d" " -f2`" in
		*GenuineIntel*) vendor=intel; printf "GenuineIntel\n";;
		*AuthenticAMD*) vendor=amd; printf "AuthenticAMD\n";;
		*CyrixInstead*) vendor=cyrix; printf "CyrixInstead\n";;
		*GenuineTMx86*) vendor=transmeta; printf "GenuineTMx86\n";;
		*) vendor=other; printf "other\n";;
	esac
else
	# allow vendor to be overridden
	vendor=${1#*=}; shift
	printf "%s\n" $vendor
fi

# quick sanity tests.
if ! test "$1"; then
	printf "usage: %s [--vendor=intel|amd|cyrix|transmeta] /path/to/binary\n" $0 1>&2
	exit 1
elif ! test -e "$1"; then 
	printf "error: %s does not exist.\n" "$1" 1>&2
	exit 1
elif ! test -r "$1"; then
	printf "error: cant read %s.\n" "$1" 1>&2
	exit 1
fi

printf "Disassembling %s, please wait...\n" $1

# initialize screen output
case "$vendor" in
	*intel*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u\r" \
		$i486 $i586 $ppro $mmx $sse $sse2;;
	*amd*) printf "i486: %4u i586: %4u mmx: %4u sse: %4u 3dnow: %4u ext3dnow: %4u\r" \
		$i486 $i586 $mmx $sse $amd $amd2;;
	*cyrix*) printf "i486: %4u i586: %4u mmx: %4u\r" \
		$i486 $i586 $mmx;;
	*transmeta*) printf "i486: %4u i586: %4u mmx: %4u\r" \
		$i486 $i586 $mmx;;
	*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u\r" \
		$i486 $i586 $ppro $mmx $sse $sse2;;
esac

# do the disassembling.
objdump -d $1 | cut -f3 | cut -d" " -f1 | (
	while read instruction; do
 		case "$instruction" in
			"cmpxchg"|"xadd"|"bswap"|"invd"|"wbinvd"|"invlpg") let ++i486; print=1;;
			"rdmsr"|"wrmsr"|"rdtsc"|"cmpxch8B"|"rsm") let ++i586; print=1;;
			"cmovcc"|"fcmovcc"|"fcomi"|"fcomip"|"fucomi"|"fucomip"|"rdpmc"|"ud2") let ++ppro; print=1;;
			"emms"|"movd"|"movq"|"packsswb"|"packssdw"|"packuswb"|"paddb"|"paddw"|"paddd"|"paddsb"|"paddsw"|"paddusb"|"paddusw"|"pand"|"pandn"|"pcmpeqb"|"pcmpeqw"|"pcmpeqd"|"pcmpgtb"|"pcmpgtw"|"pcmpgtd"|"pmaddwd"|"pmulhw"|"pmullw"|"por"|"psllw"|"pslld"|"psllq"|"psraw"|"psrad"|"psrlw"|"psrld"|"psrlq"|"psubb"|"psubw"|"psubd"|"psubsb"|"psubsw"|"psubusb"|"psubusw"|"punpckhbw"|"punpckhwd"|"punpckhdq"|"punpcklbw"|"punpcklwd"|"punpckldq"|"pxor") let ++mmx; print=1;;
			"addps"|"addss"|"andnps"|"andps"|"cmpps"|"cmpss"|"comiss"|"cvtpi2ps"|"cvtps2pi"|"cvtsi2ss"|"cvtss2si"|"cvttps2pi"|"cvttss2si"|"divps"|"divss"|"fxrstor"|"fxsave"|"ldmxcsr"|"maxps"|"maxss"|"minps"|"minss"|"movaps"|"movhlps"|"movhps"|"movlhps"|"movlps"|"movmskps"|"movss"|"movups"|"mulps"|"mulss"|"orps"|"pavgb"|"pavgw"|"psadbw"|"rcpps"|"rcpss"|"rsqrtps"|"rsqrtss"|"shufps"|"sqrtps"|"sqrtss"|"stmxcsr"|"subps"|"subss"|"ucomiss"|"unpckhps"|"unpcklps"|"xorps"|"pextrw"|"pinsrw"|"pmaxsw"|"pmaxub"|"pminsw"|"pminub"|"pmovmskb"|"pmulhuw"|"pshufw"|"maskmovq"|"movntps"|"movntq"|"prefetch"|"sfence") let ++sse; print=1;;
			"addpd"|"addsd"|"andnpd"|"andpd"|"clflush"|"cmppd"|"cmpsd"|"comisd"|"cvtdq2pd"|"cvtdq2ps"|"cvtpd2pi"|"cvtpd2pq"|"cvtpd2ps"|"cvtpi2pd"|"cvtps2dq"|"cvtps2pd"|"cvtsd2si"|"cvtsd2ss"|"cvtsi2sd"|"cvtss2sd"|"cvttpd2pi"|"cvttpd2dq"|"cvttps2dq"|"cvttsd2si"|"divpd"|"divsd"|"lfence"|"maskmovdqu"|"maxpd"|"maxsd"|"mfence"|"minpd"|"minsd"|"movapd"|"movd"|"movdq2q"|"movdqa"|"movdqu"|"movhpd"|"movlpd"|"movmskpd"|"movntdq"|"movnti"|"movntpd"|"movq"|"movq2dq"|"movsd"|"movupd"|"mulpd"|"mulsd"|"orpd"|"packsswb"|"packssdw"|"packuswb"|"paddb"|"paddw"|"paddd"|"paddq"|"paddq"|"paddsb"|"paddsw"|"paddusb"|"paddusw"|"pand"|"pandn"|"pause"|"pavgb"|"pavgw"|"pcmpeqb"|"pcmpeqw"|"pcmpeqd"|"pcmpgtb"|"pcmpgtw"|"pcmpgtd"|"pextrw"|"pinsrw"|"pmaddwd"|"pmaxsw"|"pmaxub"|"pminsw"|"pminub"|"pmovmskb"|"pmulhw"|"pmulhuw"|"pmullw"|"pmuludq"|"pmuludq"|"por"|"psadbw"|"pshufd"|"pshufhw"|"pshuflw"|"pslldq"|"psllw"|"pslld"|"psllq"|"psraw"|"psrad"|"psrldq"|"psrlw"|"psrld"|"psrlq"|"psubb"|"psubw"|"psubd"|"psubq"|"psubq"|"psubsb"|"psubsw"|"psubusb"|"psubusw"|"psubsb"|"punpckhbw"|"punpckhwd"|"punpckhdq"|"punpckhqdq"|"punpcklbw"|"punpcklwd"|"punpckldq"|"punpcklqdq"|"pxor"|"shufpd"|"sqrtpd"|"sqrtsd"|"subpd"|"subsd"|"ucomisd"|"unpckhpd"|"unpcklpd"|"xorpd") let ++sse2; print=1;;
			"pavgusb"|"pfadd"|"pfsub"|"pfsubr"|"pfacc"|"pfcmpge"|"pfcmpgt"|"pfcmpeq"|"pfmin"|"pfmax"|"pi2fw"|"pi2fd"|"pf2iw"|"pf2id"|"pfrcp"|"pfrsqrt"|"pfmul"|"pfrcpit1"|"pfrsqit1"|"pfrcpit2"|"pmulhrw"|"pswapw"|"femms"|"prefetch") let ++amd; print=1;;
			"pf2iw"|"pfnacc"|"pfpnacc"|"pi2fw"|"pswapd"|"maskmovq"|"movntq"|"pavgb"|"pavgw"|"pextrw"|"pinsrw"|"pmaxsw"|"pmaxub"|"pminsw"|"pminub"|"pmovmskb"|"pmulhuw"|"prefetchnta"|"prefetcht0"|"prefetcht1"|"prefetcht2"|"psadbw"|"pshufw"|"sfence") let ++amd2; print=1;;
			"cpuid") let ++cpuid ++i586; print=1;;
		esac
	# check if screen needs updating.
	if test "$print"; then
		case "$vendor" in
			*intel*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u\r" \
				$i486 $i586 $ppro $mmx $sse $sse2;;
			*amd*) printf "i486: %4u i586: %4u mmx: %4u sse: %4u 3dnow: %4u ext3dnow: %4u\r" \
				$i486 $i586 $mmx $sse $amd $amd2;;
			*cyrix*) printf "i486: %4u i586: %4u mmx: %4u\r" \
				$i486 $i586 $mmx;;
			*transmeta*) printf "i486: %4u i586: %4u mmx: %4u\r" \
				$i486 $i586 $mmx;;
			*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u\r" \
				$i486 $i586 $ppro $mmx $sse $sse2;;
		esac	
		unset print
	fi
	done 

# print a newline
echo

# cpuid instruction could mean the application checks to see
# if an instruction is supported before executing it. This might 
# mean it will work on anything over a pentium.
if test $cpuid -gt 0; then
	printf "\nThis binary was found to contain the cpuid instruction.\n"
	printf "It may be able to conditionally execute instructions if\n"
	printf "they are supported on the host (i586+).\n\n"
fi

# print minimum required processor, if there are collissions
# use the vendor to decide what to print.
if test $sse2 -gt 0; then 
	subarch="Pentium IV (pentium4)"
elif test $sse -gt 0; then 
	if test "$vendor" == "intel"; then
		subarch="Pentium III (pentium3)"
	elif test "$vendor" == "amd"; then
		subarch="AMD Athlon 4 (athlon-4)"
	else
		subarch="Pentium III (pentium3)"
	fi
elif test "$vendor" == "amd" -a $amd2 -gt 0; then
	subarch="AMD Athlon (athlon)"
elif test "$vendor" == "amd" -a $amd -gt 0; then
	subarch="AMD K6 III (k6-3)"
elif test $mmx -gt 0; then 
	if test "$vendor" == "intel"; then
		if $ppro -gt 0; then
			subarch="Pentium II (pentium2)"
		else
			subarch="Intel Pentium MMX [P55C] (pentium-mmx)"
		fi
	elif test "$vendor" == "amd"; then
		subarch="AMD K6 (k6)"
	elif test "$vendor" == "cyrix"; then
		subarch="Cyrix 6x86MX / MII (pentium-mmx)"
	else
		subarch="Intel Pentium MMX [P55C] (pentium-mmx)"
	fi
elif test $ppro -gt 0; then
	subarch="Pentium Pro (i686 or pentiumpro)"
elif test $i586 -gt 0; then
	subarch="Pentium or compatible (i586) (i586 or pentium)"
elif test $i486 -gt 0; then
	subarch="80486 or comaptible (i486)"
else
	subarch="80386 or compatible (i386)"
fi

# print message and exit.
printf "%s will run on %s or higher processor.\n" "$1" "$subarch"; )


[-- Attachment #3: Type: text/plain, Size: 37 bytes --]

--
gentoo-dev@gentoo.org mailing list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] Script to test instruction set.
  2003-08-12 11:55 [gentoo-dev] Script to test instruction set Tavis Ormandy
@ 2003-08-12 14:13 ` Norbert Kamenicky
  2003-08-12 14:45   ` Tavis Ormandy
  2003-08-12 14:26 ` Philippe Lafoucrière
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Norbert Kamenicky @ 2003-08-12 14:13 UTC (permalink / raw
  To: gentoo-dev; +Cc: Tavis Ormandy

I tested your script on P4 and Athlon XP Gentoo machines
built from stage1 with these CFLAGS:

P4          CFLAGS="-march=i686 -O3 -pipe"
AMD-XP CFLAGS="-march=athlon-xp -O3 -pipe"

Received the same answer:

$ bin/analyse-x86 /bin/bash
Checking vendor_id string... GenuineIntel   ( or AuthenticAMD )
Disassembling /bin/bash, please wait...
i486:    0 i586:    0 mmx:    0 sse:    0 3dnow:    0 ext3dnow:    0
/bin/bash will run on 80386 or compatible (i386) or higher processor.

So something is wrong ...

noro



Tavis Ormandy wrote:

>Hey, this is an x86 port of a script i wrote (with some help from
>wwoods) to identify what processor an alpha binary would work on.
>
>I think its pretty cool, and had some good feedback so im posting it
>here :)
>
>Example:
>
>$ ./analyse-x86 /bin/ls
>Checking vendor_id string...GenuineIntel
>Disassembling /bin/ls, please wait...
>i486:    0 i586:    0 ppro:   15 mmx:    0 sse:    8 sse2:    0
>/bin/ls will run on Pentium III (pentium3) or higher processor.
>
>  
>
>------------------------------------------------------------------------
>
>#!/bin/sh
># Tavis Ormandy <taviso@gentoo.org> 2003
># Improvments by Will Woods <wwoods@gentoo.org>
>#
># Identify instruction set used in binary.
>#
>
># initialize everything to zero.
>eval {i486,i586,ppro,mmx,sse,sse2,amd,amd2,cpuid}=0
>
># unfortunately there are mnemonic collissions between vendor sets
># so check vendor_id string, and enable relevant sets.
>printf "Checking vendor_id string..."
>if ! test "${1%=*}" == "--vendor"; then
>	case "`grep -Em1 '^vendor_id.*: ' /proc/cpuinfo | cut -d" " -f2`" in
>		*GenuineIntel*) vendor=intel; printf "GenuineIntel\n";;
>		*AuthenticAMD*) vendor=amd; printf "AuthenticAMD\n";;
>		*CyrixInstead*) vendor=cyrix; printf "CyrixInstead\n";;
>		*GenuineTMx86*) vendor=transmeta; printf "GenuineTMx86\n";;
>		*) vendor=other; printf "other\n";;
>	esac
>else
>	# allow vendor to be overridden
>	vendor=${1#*=}; shift
>	printf "%s\n" $vendor
>fi
>
># quick sanity tests.
>if ! test "$1"; then
>	printf "usage: %s [--vendor=intel|amd|cyrix|transmeta] /path/to/binary\n" $0 1>&2
>	exit 1
>elif ! test -e "$1"; then 
>	printf "error: %s does not exist.\n" "$1" 1>&2
>	exit 1
>elif ! test -r "$1"; then
>	printf "error: cant read %s.\n" "$1" 1>&2
>	exit 1
>fi
>
>printf "Disassembling %s, please wait...\n" $1
>
># initialize screen output
>case "$vendor" in
>	*intel*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u\r" \
>		$i486 $i586 $ppro $mmx $sse $sse2;;
>	*amd*) printf "i486: %4u i586: %4u mmx: %4u sse: %4u 3dnow: %4u ext3dnow: %4u\r" \
>		$i486 $i586 $mmx $sse $amd $amd2;;
>	*cyrix*) printf "i486: %4u i586: %4u mmx: %4u\r" \
>		$i486 $i586 $mmx;;
>	*transmeta*) printf "i486: %4u i586: %4u mmx: %4u\r" \
>		$i486 $i586 $mmx;;
>	*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u\r" \
>		$i486 $i586 $ppro $mmx $sse $sse2;;
>esac
>
># do the disassembling.
>objdump -d $1 | cut -f3 | cut -d" " -f1 | (
>	while read instruction; do
> 		case "$instruction" in
>			"cmpxchg"|"xadd"|"bswap"|"invd"|"wbinvd"|"invlpg") let ++i486; print=1;;
>			"rdmsr"|"wrmsr"|"rdtsc"|"cmpxch8B"|"rsm") let ++i586; print=1;;
>			"cmovcc"|"fcmovcc"|"fcomi"|"fcomip"|"fucomi"|"fucomip"|"rdpmc"|"ud2") let ++ppro; print=1;;
>			"emms"|"movd"|"movq"|"packsswb"|"packssdw"|"packuswb"|"paddb"|"paddw"|"paddd"|"paddsb"|"paddsw"|"paddusb"|"paddusw"|"pand"|"pandn"|"pcmpeqb"|"pcmpeqw"|"pcmpeqd"|"pcmpgtb"|"pcmpgtw"|"pcmpgtd"|"pmaddwd"|"pmulhw"|"pmullw"|"por"|"psllw"|"pslld"|"psllq"|"psraw"|"psrad"|"psrlw"|"psrld"|"psrlq"|"psubb"|"psubw"|"psubd"|"psubsb"|"psubsw"|"psubusb"|"psubusw"|"punpckhbw"|"punpckhwd"|"punpckhdq"|"punpcklbw"|"punpcklwd"|"punpckldq"|"pxor") let ++mmx; print=1;;
>			"addps"|"addss"|"andnps"|"andps"|"cmpps"|"cmpss"|"comiss"|"cvtpi2ps"|"cvtps2pi"|"cvtsi2ss"|"cvtss2si"|"cvttps2pi"|"cvttss2si"|"divps"|"divss"|"fxrstor"|"fxsave"|"ldmxcsr"|"maxps"|"maxss"|"minps"|"minss"|"movaps"|"movhlps"|"movhps"|"movlhps"|"movlps"|"movmskps"|"movss"|"movups"|"mulps"|"mulss"|"orps"|"pavgb"|"pavgw"|"psadbw"|"rcpps"|"rcpss"|"rsqrtps"|"rsqrtss"|"shufps"|"sqrtps"|"sqrtss"|"stmxcsr"|"subps"|"subss"|"ucomiss"|"unpckhps"|"unpcklps"|"xorps"|"pextrw"|"pinsrw"|"pmaxsw"|"pmaxub"|"pminsw"|"pminub"|"pmovmskb"|"pmulhuw"|"pshufw"|"maskmovq"|"movntps"|"movntq"|"prefetch"|"sfence") let ++sse; print=1;;
>			"addpd"|"addsd"|"andnpd"|"andpd"|"clflush"|"cmppd"|"cmpsd"|"comisd"|"cvtdq2pd"|"cvtdq2ps"|"cvtpd2pi"|"cvtpd2pq"|"cvtpd2ps"|"cvtpi2pd"|"cvtps2dq"|"cvtps2pd"|"cvtsd2si"|"cvtsd2ss"|"cvtsi2sd"|"cvtss2sd"|"cvttpd2pi"|"cvttpd2dq"|"cvttps2dq"|"cvttsd2si"|"divpd"|"divsd"|"lfence"|"maskmovdqu"|"maxpd"|"maxsd"|"mfence"|"minpd"|"minsd"|"movapd"|"movd"|"movdq2q"|"movdqa"|"movdqu"|"movhpd"|"movlpd"|"movmskpd"|"movntdq"|"movnti"|"movntpd"|"movq"|"movq2dq"|"movsd"|"movupd"|"mulpd"|"mulsd"|"orpd"|"packsswb"|"packssdw"|"packuswb"|"paddb"|"paddw"|"paddd"|"paddq"|"paddq"|"paddsb"|"paddsw"|"paddusb"|"paddusw"|"pand"|"pandn"|"pause"|"pavgb"|"pavgw"|"pcmpeqb"|"pcmpeqw"|"pcmpeqd"|"pcmpgtb"|"pcmpgtw"|"pcmpgtd"|"pextrw"|"pinsrw"|"pmaddwd"|"pmaxsw"|"pmaxub"|"pminsw"|"pminub"|"pmovmskb"|"pmulhw"|"pmulhuw"|"pmullw"|"pmuludq"|"pmuludq"|"por"|"psadbw"|"pshufd"|"pshufhw"|"pshuflw"|"pslldq"|"psllw"|"pslld"|"psllq"|"psraw"|"psrad"|"psrldq"|"psrlw"|"psrld"|"psrlq"|"psubb"|"psubw"|"psubd"|"psubq"|"psubq"|"psubsb"|"psubsw"|"psubusb"|"psubusw"|"psubsb"|"punpckhbw"|"punpckhwd"|"punpckhdq"|"punpckhqdq"|"punpcklbw"|"punpcklwd"|"punpckldq"|"punpcklqdq"|"pxor"|"shufpd"|"sqrtpd"|"sqrtsd"|"subpd"|"subsd"|"ucomisd"|"unpckhpd"|"unpcklpd"|"xorpd") let ++sse2; print=1;;
>			"pavgusb"|"pfadd"|"pfsub"|"pfsubr"|"pfacc"|"pfcmpge"|"pfcmpgt"|"pfcmpeq"|"pfmin"|"pfmax"|"pi2fw"|"pi2fd"|"pf2iw"|"pf2id"|"pfrcp"|"pfrsqrt"|"pfmul"|"pfrcpit1"|"pfrsqit1"|"pfrcpit2"|"pmulhrw"|"pswapw"|"femms"|"prefetch") let ++amd; print=1;;
>			"pf2iw"|"pfnacc"|"pfpnacc"|"pi2fw"|"pswapd"|"maskmovq"|"movntq"|"pavgb"|"pavgw"|"pextrw"|"pinsrw"|"pmaxsw"|"pmaxub"|"pminsw"|"pminub"|"pmovmskb"|"pmulhuw"|"prefetchnta"|"prefetcht0"|"prefetcht1"|"prefetcht2"|"psadbw"|"pshufw"|"sfence") let ++amd2; print=1;;
>			"cpuid") let ++cpuid ++i586; print=1;;
>		esac
>	# check if screen needs updating.
>	if test "$print"; then
>		case "$vendor" in
>			*intel*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u\r" \
>				$i486 $i586 $ppro $mmx $sse $sse2;;
>			*amd*) printf "i486: %4u i586: %4u mmx: %4u sse: %4u 3dnow: %4u ext3dnow: %4u\r" \
>				$i486 $i586 $mmx $sse $amd $amd2;;
>			*cyrix*) printf "i486: %4u i586: %4u mmx: %4u\r" \
>				$i486 $i586 $mmx;;
>			*transmeta*) printf "i486: %4u i586: %4u mmx: %4u\r" \
>				$i486 $i586 $mmx;;
>			*) printf "i486: %4u i586: %4u ppro: %4u mmx: %4u sse: %4u sse2: %4u\r" \
>				$i486 $i586 $ppro $mmx $sse $sse2;;
>		esac	
>		unset print
>	fi
>	done 
>
># print a newline
>echo
>
># cpuid instruction could mean the application checks to see
># if an instruction is supported before executing it. This might 
># mean it will work on anything over a pentium.
>if test $cpuid -gt 0; then
>	printf "\nThis binary was found to contain the cpuid instruction.\n"
>	printf "It may be able to conditionally execute instructions if\n"
>	printf "they are supported on the host (i586+).\n\n"
>fi
>
># print minimum required processor, if there are collissions
># use the vendor to decide what to print.
>if test $sse2 -gt 0; then 
>	subarch="Pentium IV (pentium4)"
>elif test $sse -gt 0; then 
>	if test "$vendor" == "intel"; then
>		subarch="Pentium III (pentium3)"
>	elif test "$vendor" == "amd"; then
>		subarch="AMD Athlon 4 (athlon-4)"
>	else
>		subarch="Pentium III (pentium3)"
>	fi
>elif test "$vendor" == "amd" -a $amd2 -gt 0; then
>	subarch="AMD Athlon (athlon)"
>elif test "$vendor" == "amd" -a $amd -gt 0; then
>	subarch="AMD K6 III (k6-3)"
>elif test $mmx -gt 0; then 
>	if test "$vendor" == "intel"; then
>		if $ppro -gt 0; then
>			subarch="Pentium II (pentium2)"
>		else
>			subarch="Intel Pentium MMX [P55C] (pentium-mmx)"
>		fi
>	elif test "$vendor" == "amd"; then
>		subarch="AMD K6 (k6)"
>	elif test "$vendor" == "cyrix"; then
>		subarch="Cyrix 6x86MX / MII (pentium-mmx)"
>	else
>		subarch="Intel Pentium MMX [P55C] (pentium-mmx)"
>	fi
>elif test $ppro -gt 0; then
>	subarch="Pentium Pro (i686 or pentiumpro)"
>elif test $i586 -gt 0; then
>	subarch="Pentium or compatible (i586) (i586 or pentium)"
>elif test $i486 -gt 0; then
>	subarch="80486 or comaptible (i486)"
>else
>	subarch="80386 or compatible (i386)"
>fi
>
># print message and exit.
>printf "%s will run on %s or higher processor.\n" "$1" "$subarch"; )
>
>  
>
>------------------------------------------------------------------------
>
>--
>gentoo-dev@gentoo.org mailing list
>


--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] Script to test instruction set.
  2003-08-12 11:55 [gentoo-dev] Script to test instruction set Tavis Ormandy
  2003-08-12 14:13 ` Norbert Kamenicky
@ 2003-08-12 14:26 ` Philippe Lafoucrière
  2003-08-12 14:43   ` Tavis Ormandy
  2003-08-12 15:37 ` Ned Ludd
  2003-08-12 18:23 ` Georgi Georgiev
  3 siblings, 1 reply; 10+ messages in thread
From: Philippe Lafoucrière @ 2003-08-12 14:26 UTC (permalink / raw
  To: Tavis Ormandy; +Cc: Gentoo-dev


> $ ./analyse-x86 /bin/ls
> Checking vendor_id string...GenuineIntel
> Disassembling /bin/ls, please wait...
> i486:    0 i586:    0 ppro:   15 mmx:    0 sse:    8 sse2:    0
> /bin/ls will run on Pentium III (pentium3) or higher processor.


did you emerge binutils using these values ?
It may come from a stage install (i686)...

here is what I have :

sh analyse-x86 --vendor=amd /bin/ls
Checking vendor_id string...amd
Disassembling /bin/ls, please wait...
i486:    0 i586:    0 mmx:    0 sse:    0 3dnow:    0 ext3dnow:    0
/bin/ls will run on Pentium Pro (i686 or pentiumpro) or higher processor


and with apache2 :

sh analyse-x86 --vendor=amd /usr/sbin/apache2    
Checking vendor_id string...amd
Disassembling /usr/sbin/apache2, please wait...
i486:    0 i586:    0 mmx:    0 sse:    0 3dnow:    0 ext3dnow:    0
/usr/sbin/apache2 will run on 80386 or compatible (i386) or higher
processor.

(my settings :
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-mp -O3 -pipe"
CXXFLAGS="${CFLAGS}"
)



--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] Script to test instruction set.
  2003-08-12 14:26 ` Philippe Lafoucrière
@ 2003-08-12 14:43   ` Tavis Ormandy
  0 siblings, 0 replies; 10+ messages in thread
From: Tavis Ormandy @ 2003-08-12 14:43 UTC (permalink / raw
  To: Philippe Lafoucri?re; +Cc: Gentoo-dev

On Tue, Aug 12, 2003 at 04:26:05PM +0200, Philippe Lafoucri?re wrote:
> 
> > $ ./analyse-x86 /bin/ls
> > Checking vendor_id string...GenuineIntel
> > Disassembling /bin/ls, please wait...
> > i486:    0 i586:    0 ppro:   15 mmx:    0 sse:    8 sse2:    0
> > /bin/ls will run on Pentium III (pentium3) or higher processor.
> 
> 
> did you emerge binutils using these values ?
> It may come from a stage install (i686)...
> 

no, i used -march=pentium4. 

not all code can take advantage of extended instruction sets, im
confident the script is correct. 

The value in brackets is the lowest value you could have passed to
-march= in gcc and have the same results (not including scheduling, which
obviously doesnt affect compatability). 

-- 
-------------------------------------
taviso@sdf.lonestar.org | finger me for my gpg key.
-------------------------------------------------------

--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] Script to test instruction set.
  2003-08-12 14:13 ` Norbert Kamenicky
@ 2003-08-12 14:45   ` Tavis Ormandy
  0 siblings, 0 replies; 10+ messages in thread
From: Tavis Ormandy @ 2003-08-12 14:45 UTC (permalink / raw
  To: gentoo-dev

On Tue, Aug 12, 2003 at 04:13:32PM +0200, Norbert Kamenicky wrote:
> I tested your script on P4 and Athlon XP Gentoo machines
> built from stage1 with these CFLAGS:
> 
> P4          CFLAGS="-march=i686 -O3 -pipe"
> AMD-XP CFLAGS="-march=athlon-xp -O3 -pipe"
> 
> Received the same answer:
> 
> $ bin/analyse-x86 /bin/bash
> Checking vendor_id string... GenuineIntel   ( or AuthenticAMD )
> Disassembling /bin/bash, please wait...
> i486:    0 i586:    0 mmx:    0 sse:    0 3dnow:    0 ext3dnow:    0
> /bin/bash will run on 80386 or compatible (i386) or higher processor.
> 
> So something is wrong ...
> 

nothing is wrong, bash doesnt contain any code that extended
instructions can be used on.

-- 
-------------------------------------
taviso@sdf.lonestar.org | finger me for my gpg key.
-------------------------------------------------------

--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] Script to test instruction set.
  2003-08-12 11:55 [gentoo-dev] Script to test instruction set Tavis Ormandy
  2003-08-12 14:13 ` Norbert Kamenicky
  2003-08-12 14:26 ` Philippe Lafoucrière
@ 2003-08-12 15:37 ` Ned Ludd
  2003-08-12 18:23 ` Georgi Georgiev
  3 siblings, 0 replies; 10+ messages in thread
From: Ned Ludd @ 2003-08-12 15:37 UTC (permalink / raw
  To: Tavis Ormandy; +Cc: gentoo-dev

Nice script guys.

On Tue, 2003-08-12 at 07:55, Tavis Ormandy wrote:
> Hey, this is an x86 port of a script i wrote (with some help from
> wwoods) to identify what processor an alpha binary would work on.
> 
> I think its pretty cool, and had some good feedback so im posting it
> here :)
> 
> Example:
> 
> $ ./analyse-x86 /bin/ls
> Checking vendor_id string...GenuineIntel
> Disassembling /bin/ls, please wait...
> i486:    0 i586:    0 ppro:   15 mmx:    0 sse:    8 sse2:    0
> /bin/ls will run on Pentium III (pentium3) or higher processor.
-- 
Ned Ludd <solar@gentoo.org>
Gentoo Linux Developer (Hardened)


--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] Script to test instruction set.
  2003-08-12 11:55 [gentoo-dev] Script to test instruction set Tavis Ormandy
                   ` (2 preceding siblings ...)
  2003-08-12 15:37 ` Ned Ludd
@ 2003-08-12 18:23 ` Georgi Georgiev
  2003-08-13  5:04   ` Joerg Plate
  3 siblings, 1 reply; 10+ messages in thread
From: Georgi Georgiev @ 2003-08-12 18:23 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 944 bytes --]

The shell script runs a little too slow, so I took the liberty of converting it
to perl. Here is why:

chutz@lion tmp $ time ./analyse-x86.sh /bin/ls
Checking vendor_id string...AuthenticAMD
Disassembling /bin/ls, please wait...
i486:    0 i586:    0 mmx:    0 sse:    0 3dnow:    0 ext3dnow:   21
/bin/ls will run on AMD Athlon (athlon) or higher processor.

real    1m1.848s
user    1m0.310s
sys     0m0.210s

chutz@lion tmp $ time ./analyse-x86.pl /bin/ls
Checking vendor_id string...AuthenticAMD
Disassembling /bin/ls, please wait...
i486:    0 i586:    0 mmx:    0 sse:    0 3dnow:    0 ext3dnow:   21
/bin/ls will run on AMD Athlon (athlon) or higher processor.

real    0m3.733s
user    0m3.610s
sys     0m0.000s

-- 
\    Georgi Georgiev   \  Beauty seldom recommends one woman to        \
/     chutz@gg3.net    /  another.                                     /
\   +81(90)6266-1163   \                                               \

[-- Attachment #2: analyse-x86.pl --]
[-- Type: application/x-perl, Size: 7959 bytes --]

[-- Attachment #3: Type: text/plain, Size: 37 bytes --]

--
gentoo-dev@gentoo.org mailing list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] Script to test instruction set.
  2003-08-12 18:23 ` Georgi Georgiev
@ 2003-08-13  5:04   ` Joerg Plate
  2003-08-13  8:08     ` Georgi Georgiev
  0 siblings, 1 reply; 10+ messages in thread
From: Joerg Plate @ 2003-08-13  5:04 UTC (permalink / raw
  To: gentoo-dev


time for /bin/ls (80KB)

Shell: 42 seconds
Perl1: 14 seconds
Perl2:  1 second

time for /usr/bin/ghemical (9.2MB)
Perl2: 27 seconds

--- analyse-x86.pl	2003-08-13 06:46:05.000000000 +0200
+++ analyse-x86	2003-08-13 06:53:16.424813198 +0200
@@ -59,4 +59,7 @@
 my $print;
+my %done;
 while (defined (my $instruction = <PIPE>)) {
 	chomp $instruction; 
+	next if $done{$instruction};
+	$done{$instruction}++;
 	if (scalar (grep /^$instruction$/, "cmpxchg","xadd","bswap","invd","wbinvd","invlpg")) { $i486++; $print=1 }

-- 
"I'm working on it."  <http://Patterner.de>

--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] Script to test instruction set.
  2003-08-13  5:04   ` Joerg Plate
@ 2003-08-13  8:08     ` Georgi Georgiev
  2003-08-13  8:24       ` Georgi Georgiev
  0 siblings, 1 reply; 10+ messages in thread
From: Georgi Georgiev @ 2003-08-13  8:08 UTC (permalink / raw
  To: gentoo-dev

On 13/08/2003 at 07:04:09(+0200), Joerg Plate used 0.6K just to say:
> --- analyse-x86.pl	2003-08-13 06:46:05.000000000 +0200
> +++ analyse-x86	2003-08-13 06:53:16.424813198 +0200
> @@ -59,4 +59,7 @@
>  my $print;
> +my %done;
>  while (defined (my $instruction = <PIPE>)) {
>  	chomp $instruction; 
> +	next if $done{$instruction};
> +	$done{$instruction}++;
>  	if (scalar (grep /^$instruction$/, "cmpxchg","xadd","bswap","invd","wbinvd","invlpg")) { $i486++; $print=1 }
> 

Nice. Here is a little cosmetic patch to finish this off

$ patch
--- analyse-x86     2003-08-13 16:53:05.000000000 +0900
+++ analyse-x86     2003-08-13 16:50:58.000000000 +0900
@@ -8,7 +8,7 @@
 #

 # initialize everything to zero.
-my ($i486,$i586,$ppro,$mmx,$sse,$sse2,$amd,$amd2,$cpuid) = (0,0,0,0,0,0,0,0,0);
+my ($i486,$i586,$ppro,$mmx,$sse,$sse2,$amd,$amd2,$cpuid) = ("","","","","","","","","");
 my ($vendor, $subarch);
 # unfortunately there are mnemonic collissions between vendor sets
 # so check vendor_id string, and enable relevant sets.

patching file analyse-x86
$ perl -pi -e 's/%4u/[%1.1s]/g' analyse-x86
$ perl -pi -e 's/\+\+/="Y"/g'   analyse-x86
$ ./analyse-x86 /bin/ls
Checking vendor_id string...AuthenticAMD
Disassembling /bin/ls, please wait...
i486: [ ] i586: [ ] mmx: [ ] sse: [ ] 3dnow: [ ] ext3dnow: [Y]
/bin/ls will run on AMD Athlon (athlon) or higher processor.


-- 
(*   Georgi Georgiev   (* Are you tired of being a crash test dummy    (*
*)    chutz@gg3.net    *) for Microsoft? Discover Linux. -- Gareth     *)
(*  +81(90)6266-1163   (* Barnard                                      (*

--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [gentoo-dev] Script to test instruction set.
  2003-08-13  8:08     ` Georgi Georgiev
@ 2003-08-13  8:24       ` Georgi Georgiev
  0 siblings, 0 replies; 10+ messages in thread
From: Georgi Georgiev @ 2003-08-13  8:24 UTC (permalink / raw
  To: gentoo-dev

Ooops...

--- analyse-x86     2003-08-13 08:21:42.000000000 +0000
+++ analyse-x86     2003-08-13 08:21:20.000000000 +0000
@@ -14,7 +14,7 @@
 # so check vendor_id string, and enable relevant sets.
 print "Checking vendor_id string...";
 my $param = shift;
-unless (defined $param and $param eq "--vendor") {
+unless (defined $param and $param =~ /^--vendor=/) {
        open PIPE, "grep -Em1 '^vendor_id.*: ' /proc/cpuinfo | cut -d' ' -f2 | " or die;
        $_ = <PIPE>;
        close PIPE;


-- 
(    Georgi Georgiev   (  To make tax forms true they should read      (
 )    chutz@gg3.net     ) "Income Owed Us" and "Incommode You".         )
(   +81(90)6266-1163   (                                               (

--
gentoo-dev@gentoo.org mailing list


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-08-13  8:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-12 11:55 [gentoo-dev] Script to test instruction set Tavis Ormandy
2003-08-12 14:13 ` Norbert Kamenicky
2003-08-12 14:45   ` Tavis Ormandy
2003-08-12 14:26 ` Philippe Lafoucrière
2003-08-12 14:43   ` Tavis Ormandy
2003-08-12 15:37 ` Ned Ludd
2003-08-12 18:23 ` Georgi Georgiev
2003-08-13  5:04   ` Joerg Plate
2003-08-13  8:08     ` Georgi Georgiev
2003-08-13  8:24       ` Georgi Georgiev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox