wok diff linld/stuff/src/pipehole.awk @ rev 24034

Openssh (8.5p1)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Apr 08 09:21:26 2021 +0000 (2021-04-08)
parents 526688f99354
children 06547d8cf241
line diff
     1.1 --- a/linld/stuff/src/pipehole.awk	Mon Mar 15 20:49:46 2021 +0000
     1.2 +++ b/linld/stuff/src/pipehole.awk	Thu Apr 08 09:21:26 2021 +0000
     1.3 @@ -7,7 +7,10 @@
     1.4  	if (/^@.*:$/ || /	endp$/) afterjmp=0
     1.5  	if (/^	\.386p$/) is386=1
     1.6  	if (file == "" && /debug	S/) { file=$3; gsub(/\"/,"",file) }
     1.7 -	if (/debug	S/) print "	%PAGESIZE 1000"
     1.8 +	if (/debug	S/) {
     1.9 +		print "	%PAGESIZE 255"
    1.10 +		print "	include	common.inc"
    1.11 +	}
    1.12  	 if (file == "linld.cpp") {
    1.13  	if (/\[si/ || /si,/ || /,si/) sub(/si/,"di")
    1.14  	else if (/\[di/ || /di,/ || /,di/) sub(/di/,"si")
    1.15 @@ -67,7 +70,7 @@
    1.16  	}
    1.17  	if (ishimem == 1) {
    1.18  		if (/do \{/) ishimem=2
    1.19 -		if (/bx,si/ || /push	bp/ || /bp,sp/ || /push	di/ || /push	si/) next
    1.20 +		if (/bx,si/ || /di,ax/ || /push	bp/ || /bp,sp/ || /push	di/ || /push	si/) next
    1.21  		if (/sp,2/ || /bp\+4/) next
    1.22  	}
    1.23  	if (ishimem == 2) {
    1.24 @@ -252,6 +255,16 @@
    1.25  	}
    1.26  	 } # file == "load.cpp"
    1.27  	 if (file == "iso9660.cpp") {
    1.28 +	if (swapsidi == 1) {
    1.29 +		if (/\[si/) sub(/\[si/,"[di")
    1.30 +		else (/\[di/) sub(/\[di/,"[si")
    1.31 +		if (/\+si/) sub(/\+si/,"+di")
    1.32 +		else (/\+di/) sub(/\+di/,"+si")
    1.33 +		if (/,si/) sub(/,si/,",di")
    1.34 +		else if (/,di/) sub(/,di/,",si")
    1.35 +		if (/si,/) sub(/si,/,"di,")
    1.36 +		else if (/di,/) sub(/di,/,"si,")
    1.37 +	}
    1.38  	if (/di,offset DGROUP:_buf2k/) { si="si"; di="di" }
    1.39  	if (/si,offset DGROUP:_buf2k/) { si="di"; di="si" }
    1.40  	if (/leave/ || /enter/ || /bp/ || /sub	sp,/) next
    1.41 @@ -260,22 +273,32 @@
    1.42  	if (/ptr \[.i\+6\],eax/) next
    1.43  	if (/x,word ptr \[.i\+32\]/) next
    1.44  	if (/add	word ptr \[.i\],ax/) sub(/ax/,"cx")
    1.45 -	if (/ax,word ptr \[si\+22\]/) sub(/mov	ax,/,"les	ax,d")
    1.46 -	if (/ax,word ptr \[si\+24\]/) next
    1.47 -	if (/word ptr \[si\+27\],ax/) sub(/ax/,"es")
    1.48 +	if (/ax,word ptr \[si\+18\]/) sub(/mov	ax,/,"les	ax,d")
    1.49 +	if (/ax,word ptr \[si\+20\]/) next
    1.50 +	if (/word ptr \[si\+25\],ax/) sub(/ax/,"es")
    1.51  	sub(/di,word ptr DGROUP:_isostate\+2/,"di,word ptr [si+2]")
    1.52 +	if (/-257/) isiso=22
    1.53 +	if (isiso == 22) {
    1.54 +		sub(/-257/,"-257	; clear C")
    1.55 +		if (/je/) {
    1.56 +			print "	cbw"
    1.57 +			print "	xchg	ax,bx"
    1.58 +			print "	xchg	ax,dx		; .. or ."
    1.59 +			$0="	je	returnC"
    1.60 +		}
    1.61 +	}
    1.62  	if (/p = buf2k \+ 32 \+ x->curpos/) isiso=21
    1.63 -	sub(/-257/,"-257	; clear C")
    1.64  	if (isiso == 21) { # ISO9660.LST
    1.65  		if (/ax,/) next
    1.66 -		if (/si,ax/) {
    1.67 -			print "	add	ax,32"
    1.68 -			$0="	xchg	ax,si"
    1.69 -		}
    1.70 +		if (/.i,ax/) sub(/mov/,"xchg")
    1.71  		if (/# else/) isiso=0
    1.72  	}
    1.73 -	if (/cx,si/) {
    1.74 -		if (isiso == 0) print "	inc	" di
    1.75 +	if (/cx,.i/) {
    1.76 +		if (isiso == 0) {
    1.77 +			print "	ifndef	CLEAN_ISO9660"
    1.78 +			print "	inc	" di
    1.79 +			print "	mov	cx," di
    1.80 +		}
    1.81  		isiso=20
    1.82  	}
    1.83  	if (isiso == 20) { # ISO9660.LST
    1.84 @@ -283,13 +306,33 @@
    1.85  			isiso=12
    1.86  			next
    1.87  		}
    1.88 +		if (/add	.i,ax/ || /cbw/) next
    1.89 +		if (/cmp/) sub(/\[/,"[bx+")
    1.90  		if (/inc	cx/) next
    1.91 -		if (/al,byte ptr/) $0="	;inc	ax"
    1.92 +		if (/sub/) sub(/.i/,"bx")
    1.93 +		sub(/inc	.i/,"inc	bx")
    1.94 +		if (/al,byte ptr/) {
    1.95 +			next
    1.96 +		}
    1.97 +		sub(/i-1\],12603/,"i],12603")
    1.98 +		if (/bx\+.i\],46/) {
    1.99 +			print "	inc	" di
   1.100 +			print "	mov	cx," di
   1.101 +		}
   1.102  		if (/i],0/) {
   1.103 -			sub(/,0/,",ah	; clear C")
   1.104 -			sub(/mov/,"and")
   1.105 +			print "	ifndef	CLEAN_ISO9660"
   1.106 +			print "	inc	" di
   1.107 +			print "	mov	cx," di
   1.108 +			print "	endif"
   1.109 +			print "seteos:"
   1.110 +			sub(/,0/,",bh	; clear C")
   1.111 +			sub(/mov	byte ptr \[/,"and	byte ptr [bx+")
   1.112  		}
   1.113 -		sub(/cx/,"dx")
   1.114 +		if (/cx,.i/) next
   1.115 +		if (/\}/) {
   1.116 +			print "	xchg	ax,cx"
   1.117 +		}
   1.118 +		if (/cx,5/) $0="	lea	dx,[" di "+5]" 
   1.119  		if (/filename = s;/) {
   1.120  			isiso=0
   1.121  		}
   1.122 @@ -297,15 +340,16 @@
   1.123  	if (isiso == 19) { # ISO9660.LST
   1.124  		if (/short @2@310/) $0="	jc	restoreC"
   1.125  		if (/si\+32/ || /ax,dx/ || /ax,di/ || /cmp	ax,-1/ || /sub	ax,/) next
   1.126 -		sub(/dx,/,"ax,")
   1.127 -		if (/ax,word ptr \[si\+18\]/) sub(/ax/,"bx")
   1.128 +		if (/ax,word ptr \[si\+28\]/) next
   1.129  		if (/bx,offset/) sub(/bx/,"ax")
   1.130 +		sub(/dx,/,"bx,")
   1.131  		if (/short @2@282/) sub(/je/,"jnc")
   1.132 -		if (/\[si\+35\],0/) sub(/,0/,",ch")
   1.133 +		if (/\[si\+30\],0/) $0="	;or	cl,cl"
   1.134 +		if (/short @2@478/) sub(/je/,"jcxz")
   1.135  		if (/@strcmp\$qpxzct1/) {
   1.136  			print
   1.137  			print "restoreC:"
   1.138 -			$0="	mov	byte ptr [di],cl	; c"
   1.139 +			$0="	mov	byte ptr [di],dl	; c"
   1.140  			isiso=1
   1.141  		}
   1.142  	}
   1.143 @@ -313,9 +357,9 @@
   1.144  		if (/endif/) isiso=1
   1.145  	}
   1.146  	if (isiso == 17) { # ISO9660.LST
   1.147 -		if (/si\+22/) {
   1.148 +		if (/si\+18/) {
   1.149  			print "next:"
   1.150 -			print "	mov	word ptr [si+24],bx"
   1.151 +			print "	mov	word ptr [si+20],bx"
   1.152  			print
   1.153  			isiso=0
   1.154  		}	
   1.155 @@ -339,7 +383,7 @@
   1.156  		if (/cmp/) {
   1.157  			print "	mov	bx,word ptr [si+7]"
   1.158  			print "	mov	ax,word ptr [si+11]"
   1.159 -			print "	dec	cx"
   1.160 +			print "	dec	dx"
   1.161  			print "	jns	next"
   1.162  		}
   1.163  		if (/isolseek/) isiso=1
   1.164 @@ -350,11 +394,16 @@
   1.165  	if (isiso == 15) { # ISO9660.LST
   1.166  		if (/xor/) {
   1.167  			print	"returnC:"
   1.168 -			print	"	sbb	ax,ax"
   1.169 +			print	"	sbb	dx,dx"
   1.170  			print	"return:"
   1.171  			next
   1.172  		}
   1.173 -		if (/i\+18\],cx/) sub(/cx/,"dx")
   1.174 +		if (/i\+28\],cx/) {
   1.175 +			print	"	ifndef BASIC_ISO9660"
   1.176 +			print	"	xchg	ax,dx"
   1.177 +			print	"	endif"
   1.178 +			next
   1.179 +		}
   1.180  		if (/@1@422:/) next
   1.181  		if (/\[di\],47/) isiso=17
   1.182  	}
   1.183 @@ -371,10 +420,10 @@
   1.184  	}
   1.185  	if (/p = buf2k \+ 34/) isiso=13
   1.186  	if (isiso == 13) { # ISO9660.LST
   1.187 -		if (/cbw/) $0="	;cbw"
   1.188 +		#if (/cbw/) $0="	;cbw"
   1.189  		if (/i,.i/) $0="	xchg	ax,bx"
   1.190  		if (/i,ax/) $0="	xchg	ax," di 
   1.191 -		if (/i,70/ || /word ptr \[.i\+32\]/) next
   1.192 +		if (/i,70/ || /ptr \[.i\+32\]/) next
   1.193  		if (/register len/) {
   1.194  			isiso=12
   1.195  		}
   1.196 @@ -382,16 +431,28 @@
   1.197  	if (isiso == 12) { # ISO9660.LST
   1.198  		if (/.i\+2/) sub(/al/,"bl")
   1.199  		if (/cbw/) next
   1.200 -		sub(/dx,ax/,"bh,0")
   1.201 +		if (/dx,ax/) next
   1.202  		if (/bx,dx/) next
   1.203  		sub(/i,dx/,"i,bx")
   1.204  		sub(/cx,/,"dx,")
   1.205 -		if (/bx\+.i\],0/) sub(/,0/,",bh")
   1.206 +		if (/bx\+.i\],0/) {
   1.207 +			sub(/,0/,",bh")
   1.208 +		}
   1.209 +		if (/jmp/) {
   1.210 +			print
   1.211 +			$0="	endif"
   1.212 +		}
   1.213 +		if (/jne/) {
   1.214 +			print "	ifdef	BASIC_ISO9660"
   1.215 +			print "	lea	cx,[" di "+5]" 
   1.216 +			print "	je	seteos"
   1.217 +			print "	else"
   1.218 +		}
   1.219  		if (/while/) isiso=120
   1.220  	}
   1.221  	if (isiso == 120) { # ISO9660.LST
   1.222 -		sub(/ax/,"bx")
   1.223 -		if (/cmp	bx,/) $0="	cmp	" di ",bx"
   1.224 +		sub(/ax/,"cx")
   1.225 +		if (/cmp	cx,/) $0="	cmp	" di ",cx"
   1.226  		sub(/jae/,"jb")
   1.227  		if (/endif/) isiso=0
   1.228  	}
   1.229 @@ -421,11 +482,37 @@
   1.230  	}
   1.231  	if (/filesize =/) isiso=8
   1.232  	if (isiso == 8) { # ISO9660.LST
   1.233 -		if (/ax,/) next
   1.234 +		if (/ax,/ || /cbw/) next
   1.235  		sub(/mov	dx,/,"les	dx,d")
   1.236  		sub(/\],ax/,"],es")
   1.237  		sub(/cx,/,"dx,")
   1.238 -		if (/sub/) isiso=0
   1.239 +		if (/DGROUP:s@\+/) {
   1.240 +			print
   1.241 +			next
   1.242 +		}
   1.243 +		if (/i\+33]/) {
   1.244 +			print "	ifdef	ROCKRIDGE"
   1.245 +			print "	 ifdef	BASIC_ISO9660"
   1.246 +			print "	add	" di ",32"
   1.247 +			print "	mov	ax,[" di "]"
   1.248 +			print "	 else"
   1.249 +			print "	mov	ax,[" di "+32]"
   1.250 +			print "	 endif"
   1.251 +			print "	mov	bl,ah"
   1.252 +			print "	mov	bh,0"
   1.253 +			print "	else"
   1.254 +			print "	mov	al,[" di "+33]"
   1.255 +			print "	cbw"
   1.256 +			$0="	endif"
   1.257 +		}
   1.258 +		if (/sub/) {
   1.259 +			print "	ifdef	ROCKRIDGE"
   1.260 +			print "	sub	dx,bx"
   1.261 +			print "	else"
   1.262 +			print 
   1.263 +			$0="	endif"
   1.264 +			isiso=0
   1.265 +		}
   1.266  	}
   1.267  	if (/entrysize =/) isiso=5
   1.268  	if (isiso == 5) { # ISO9660.LST
   1.269 @@ -454,17 +541,31 @@
   1.270  		sub(/cmp	byte ptr \[.i\]/,"sub	al")
   1.271  		if (/inc	/) { r=$2; print; next }
   1.272  		if (/al,0/) print "	mov	al,[" r "]"
   1.273 +		if (/word ptr \[si\],-1/) $0="	not	word ptr [si]	; zero'd in BSS"
   1.274 +		sub(/al,32/,"ax,32")
   1.275 +		if (/byte ptr \[si\+30\],al/) $0="	xchg	ax,cx"
   1.276  		if (/al,byte ptr \[/) next
   1.277  		if (/byte ptr \[.*\],0/) next
   1.278  		if (/byte ptr \[si\+31\],al/) next
   1.279  	}
   1.280 -	if (/ptr .isoreaddir/) isiso=1
   1.281 +	if (/ptr .isoreaddir/) {
   1.282 +		print "	ifdef	ISOHOOK"
   1.283 +		print "	push	cx"
   1.284 +		print
   1.285 +		print "	pop	cx"
   1.286 +		print "	else"
   1.287 +		print
   1.288 +		$0="	endif"
   1.289 +		isiso=1
   1.290 +	}
   1.291  	if (isiso == 1) { # ISO9660.LST
   1.292 -		if (/xor/) isiso=18
   1.293 +		if (/xor/) {
   1.294 +			$0="	xor	cl,32"
   1.295 +			isiso=18
   1.296 +		}
   1.297  		if (/n = name;/) {
   1.298  			isiso=19
   1.299 -			print "	xchg	ax,cx"
   1.300 -			print "	xchg	cl,byte ptr [di]	; c"
   1.301 +			print "	xchg	dl,byte ptr [di]	; c"
   1.302  		}
   1.303  		sub(/jne/,"jnc")
   1.304  		if (/short @2@450/) $0="	jc	returnC"
   1.305 @@ -479,7 +580,12 @@
   1.306  		if (/@2@142$/) print "	inc	di"
   1.307  	}
   1.308  	if (/i\+34\]/) next
   1.309 -	sub(/di,offset DGROUP:_isostate/,"di,si")
   1.310 +	if (/di,offset DGROUP:_isostate/) {
   1.311 +		sub(/mov/,";mov")
   1.312 +		sub(/di,/,"si,")
   1.313 +		swapsidi=1
   1.314 +	}
   1.315 +	if (/^	ret/) swapsidi=0
   1.316  	 } # file == "iso9660.cpp"
   1.317  	if (wascall) {
   1.318  		if (rcall != "") {