wok-current diff linld/stuff/src/pipehole.awk @ rev 24019

syslinux: fix build
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Feb 28 16:32:57 2021 +0000 (2021-02-28)
parents 14ca5e18cfd9
children 42b4b9d947f3
line diff
     1.1 --- a/linld/stuff/src/pipehole.awk	Thu Feb 25 10:56:54 2021 +0000
     1.2 +++ b/linld/stuff/src/pipehole.awk	Sun Feb 28 16:32:57 2021 +0000
     1.3 @@ -1,4 +1,4 @@
     1.4 -BEGIN { hold=0; is386=0; isload=0; isiso=0; istazboot=0; wascall=0; ishimem=0; label="none"; xlabel=""; file="" }
     1.5 +BEGIN { hold=0; is386=0; isload=0; isiso=0; istazboot=0; wascall=0; ishimem=0; label="none"; xlabel=""; file=""; retc="returnCz:\n" }
     1.6  function isnum(n) { return match(n,/^[0-9+-]/) }
     1.7  {
     1.8  	sub(/segment word public/,"segment byte public")
     1.9 @@ -48,7 +48,7 @@
    1.10  	}
    1.11  	 } # file == "linld.cpp"
    1.12  	 if (file == "himem.cpp") {
    1.13 -	if (/sp,bp/ || /pop	bp/) next
    1.14 +	if (/sp,bp/ || /pop	bp/ || /enter/ || /leave/) next
    1.15  	if (/void load_image/) ishimem=1
    1.16  	if (ishimem == 1 && is386 == 0) {
    1.17  		if (/si\+8\]$/ || /si\+4\]$/ || /si\+16\]$/) next
    1.18 @@ -243,15 +243,30 @@
    1.19  	}
    1.20  	 } # file == "load.cpp"
    1.21  	 if (file == "iso9660.cpp") {
    1.22 -	if (/ptr \[si\+10\],dx/) next
    1.23 -	if (/ptr \[si\+8\],ax/) next
    1.24 -	if (/si\+32/) next
    1.25 -	if (/add	word ptr \[si\],ax/) $0="	add	word ptr [si],cx"
    1.26 +	if (/ptr \[si\+8\],/) { si="si"; di="di" }
    1.27 +	if (/ptr \[di\+8\],/) { si="di"; di="si" }
    1.28 +	if (/leave/ || /enter/) next
    1.29 +	if (/ptr \[.i\+10\],dx/) next
    1.30 +	if (/ptr \[.i\+8\],ax/) next
    1.31 +	if (/ptr \[.i\+8\],eax/) next
    1.32 +	if (/cx,word ptr \[.i\+32\]/) next
    1.33 +	if (/add	word ptr \[.i\],ax/) sub(/ax/,"cx")
    1.34  	if (/ax,word ptr \[si\+24\]/) sub(/mov	ax,/,"les	ax,d")
    1.35  	if (/ax,word ptr \[si\+26\]/) next
    1.36  	if (/word ptr \[si\+29\],ax/) sub(/ax/,"es")
    1.37  	if (/\[si\],-1/) $0="	not	word ptr [si]"
    1.38  	sub(/di,word ptr DGROUP:_isostate\+2/,"di,word ptr [si+2]")
    1.39 +	if (/s = p \+ 1;/ && !/ ;/) isiso=20
    1.40 +	if (isiso == 20) { # ISO9660.LST
    1.41 +		if (/al,byte ptr/) $0="	;inc	ax"
    1.42 +		sub(/\[si-1\]/,"[si]")
    1.43 +		if (/p != .\./) print "	inc	" di "	; see ;inc ax"
    1.44 +		if (/i],0/) sub(/,0/,",ah")
    1.45 +		if (/filename = s;/) {
    1.46 +			print "	stc"
    1.47 +			isiso=0
    1.48 +		}
    1.49 +	}
    1.50  	if (isiso == 19) { # ISO9660.LST
    1.51  		if (/short @2@282/) $0="	jc	restoreC"
    1.52  		if (/bp-2/ || /si\+34/ || /ax,dx/ || /cmp	ax,-1/) next
    1.53 @@ -298,14 +313,12 @@
    1.54  		if (/si\+24/) isiso=1
    1.55  	}
    1.56  	if (/found:/) isiso=15
    1.57 -	if (/short @1@394/) sub(/@1@394/,"@1@422")
    1.58  	if (isiso != 15 && /si,offset DGROUP:_isostate/) $0=";" $0
    1.59  	if (isiso == 15) { # ISO9660.LST
    1.60  		if (/xor/) {
    1.61  			print	"returnNotC:"
    1.62  			print	"	cmc"
    1.63 -			print	"returnC:"
    1.64 -			print	"@1@422:"
    1.65 +			print	retc "returnC:"
    1.66  			print	"	sbb	ax,ax"
    1.67  			print	"return:"
    1.68  			next
    1.69 @@ -316,25 +329,26 @@
    1.70  	if (/short @1@142/) { isiso=14; next }
    1.71  	if (isiso == 14) { # ISO9660.LST
    1.72  		if (/ax,-1/) next
    1.73 -		if (/jmp	@1@422/) sub(/jmp/,"jb")
    1.74 +		if (/jmp/) $0="	jb	returnCz"
    1.75  	}
    1.76  	if (/p = x->buffer \+ 34/) isiso=13
    1.77  	if (isiso == 13) { # ISO9660.LST
    1.78 -		if (/di,si/) $0="	xchg	ax,bx"
    1.79 -		if (/di,ax/) $0="	lea	di,[si+bx+72]"
    1.80 -		if (/di,72/) {
    1.81 -			isiso=0
    1.82 -			next
    1.83 -		}
    1.84 +		if (/i,.i/) $0="	xchg	ax,bx"
    1.85 +		if (/i,ax/) $0="	lea	" di ",[bx+" si "+72]"
    1.86 +		if (/i,72/ || /word ptr \[.i\+32\]/) next
    1.87 +		if (/register len/) isiso=12
    1.88  	}
    1.89 -	if (/register len/) isiso=12
    1.90  	if (isiso == 12) { # ISO9660.LST
    1.91 -		if (/di\+2/) sub(/al/,"bl")
    1.92 +		if (/.i\+2/) sub(/al/,"bl")
    1.93  		if (/cbw/) next
    1.94  		sub(/dx,ax/,"bh,0")
    1.95  		if (/bx,dx/) next
    1.96  		sub(/i,dx/,"i,bx")
    1.97 -		sub(/bx\+di\],0/,"bx+di],bh")
    1.98 +		if (/bx\+.i\],0/) sub(/,0/,",bh")
    1.99 +		if (/jmp/) {
   1.100 +			$0=retc "	jmp	returnC"
   1.101 +			retc=""
   1.102 +		}
   1.103  		if (/while/) isiso=0
   1.104  	}
   1.105  	if (/curpos >= SECT/) isiso=10
   1.106 @@ -370,15 +384,19 @@
   1.107  	if (/entrysize =/) isiso=5
   1.108  	if (isiso == 5) { # ISO9660.LST
   1.109  		if (/ax,ax/) next
   1.110 +		if (/word ptr \[.i\+32\],ax/) next
   1.111  		sub(/ax/,"cx")
   1.112  		sub(/je/,"jcxz")
   1.113  		if (/jcxz/) {
   1.114  			hold=0
   1.115  			print	s
   1.116 -			sub(/@1@114/,"@1@394")
   1.117 +			sub(/@1@114/,"returnNotC")
   1.118  			print
   1.119 -			print "	mov	word ptr [si+10],dx"
   1.120 -			$0="	mov	word ptr [si+8],ax"
   1.121 +			if (is386) $0="	mov	dword ptr [" si "+8],eax"
   1.122 +			else {
   1.123 +				print "	mov	word ptr [" si "+10],dx"
   1.124 +				$0="	mov	word ptr [" si "+8],ax"
   1.125 +			}
   1.126  		}
   1.127  		if (/return/) isiso=0
   1.128  	}