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

linld: skip xmm_alloc
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Dec 12 10:41:29 2020 +0000 (2020-12-12)
parents a1fa13454a0c
children 34d90fb03f57
line diff
     1.1 --- a/linld/stuff/src/pipehole.awk	Sun Dec 06 10:04:52 2020 +0000
     1.2 +++ b/linld/stuff/src/pipehole.awk	Sat Dec 12 10:41:29 2020 +0000
     1.3 @@ -33,11 +33,13 @@
     1.4  	if (/== 0x662F/) islinld=2
     1.5  	if (islinld==2) {
     1.6  		if (/cpuhaslm/) islinld=0
     1.7 -		if (/mov/) { print "; " $0; next }
     1.8 +		if (/bx,word/) { print "; " $0; next }
     1.9  	}
    1.10  	if (/image\|initrd/) islinld=3
    1.11  	if (islinld==3) {
    1.12 -		if (/bx,word ptr/) { islinld=0; print "; " $0; next }
    1.13 +		if (/bx,word ptr/) { print "; " $0; next }
    1.14 +		if (/short @1@282/) print "	mov	bx,word ptr [si]"
    1.15 +		if (/@fileexist\$qpxzc/) islinld=0
    1.16  	}
    1.17  	if (/fileexist\$qpxzc/) islinld=4
    1.18  	if (islinld==4) {
    1.19 @@ -45,14 +47,15 @@
    1.20  		if (/ax,word ptr/) $0="	xchg	ax,bx"
    1.21  		if (/\[si\]$/) { islinld=0; print "; " $0; next }
    1.22  	}
    1.23 +	if (/buf_cmdline\+1/) {
    1.24 +		islinld=5
    1.25 +		print "	mov	bx,offset DGROUP:buf_cmdline+1"
    1.26 +		sub(/offset DGROUP:buf_cmdline\+1/,"bx")
    1.27 +	}
    1.28  	if (islinld==5) {
    1.29 -		if (/si/ || /word ptr/) next
    1.30 -		if (/buf_cmdline/) {
    1.31 -			print	"	lodsw"
    1.32 -			islinld=0
    1.33 -		}
    1.34 +		if (/bx,offset DGROUP:buf_cmdline/) $0="	dec	bx"
    1.35 +		if (/call/) islinld=0
    1.36  	}
    1.37 -	if (/do strcatb/) islinld=5
    1.38  	 } # file == "linld.cpp"
    1.39  	 if (file == "himem.cpp") {
    1.40  	if (/sp,bp/ || /pop	bp/) next
    1.41 @@ -65,7 +68,6 @@
    1.42  	}
    1.43  	if (ishimem == 1) {
    1.44  		if (/do \{/) ishimem=2
    1.45 -		if (/byte ptr DGROUP:_vcpi,0/) print "	mov	bx,si"
    1.46  		if (/bx,si/ || /push	bp/ || /bp,sp/ || /push	di/ || /push	si/) next
    1.47  		if (/sp,2/) next
    1.48  		if (/bp\+4/) {
    1.49 @@ -74,7 +76,7 @@
    1.50  	}
    1.51  	if (ishimem == 2) {
    1.52  		if (/movzx/) print "	cwde"
    1.53 -		if (/bp-2/) next
    1.54 +		if (/bp-2/ || /di,ax/ || /bx,di/) next
    1.55  		if (/storepage.bufv/) {
    1.56  			print "	inc	ax"
    1.57  			print "	push	ax"
    1.58 @@ -84,8 +86,35 @@
    1.59  		}
    1.60  		if (/endp/) ishimem=0
    1.61  	}
    1.62 +	if (/@memcpy_image\$qp11image_himem/) next
    1.63 +	if (/far last_ditch/) {
    1.64 +		print "	extrn	memcpy_image_kernel:near"
    1.65 +		print "	extrn	memcpy_image_initrd:near"
    1.66 +		ishimem=3
    1.67 +		cpy_initrd=0
    1.68 +	}
    1.69 +	if (ishimem == 3) {
    1.70 +		if (/bx,di/ || /di,ax/ || /bx,32/) next
    1.71 +		if (/mov	bx,si/) {
    1.72 +			if (cpy_initrd==0) sub(/mov	bx,si/, "call	memcpy_image_kernel")
    1.73 +			else sub(/mov	bx,si/, "call	memcpy_image_initrd")
    1.74 +			cpy_initrd=1-cpy_initrd
    1.75 +		}
    1.76 +		sub(/lea	bx,\[si\+32\]/, "call	memcpy_image_initrd")
    1.77 +	}
    1.78 +	if (/m = pm2initrd/) ishimem=4
    1.79 +	if (ishimem == 4) {
    1.80 +		if (/si,32/ || /bx,di/ || /di,ax/) next
    1.81 +		sub(/\[si/,"[si+32")
    1.82 +		sub(/mov	bx,si/, "call	memcpy_image_initrd")
    1.83 +	}
    1.84  	 } # file == "himem.cpp"
    1.85  	 if (file == "load.cpp") {
    1.86 +	if (/readrm\(m, 0x200/) isload=15
    1.87 +	if (isload == 15) {  # LOAD.LST
    1.88 +		if (/bx,di/) next
    1.89 +		if (/call/) isload=0
    1.90 +	}
    1.91  	if (/load_image\(/) {
    1.92  		if (isload == 3) isload=13
    1.93  		else isload=14
    1.94 @@ -120,7 +149,7 @@
    1.95  	sub(/_imgs\+65534/,"_imgs-2")
    1.96  	if (/m, _rm_size/) isload=10
    1.97  	if (isload == 10) {  # LOAD.LST
    1.98 -		if (/^	je	/) next
    1.99 +		if (/^	je	/ || /bx,di/) next
   1.100  		if (/ptr @die\$qpxzc/) {
   1.101  			$0="	jne	@die@"
   1.102  			isload=0
   1.103 @@ -152,7 +181,7 @@
   1.104  			sub(/dx/,"ax")
   1.105  		}
   1.106  	}
   1.107 -	if (/_version_string,0/) {
   1.108 +	if (/pm_low == 0/) {
   1.109  		print "	mov	ax,si"
   1.110  		print "	push	di"
   1.111  		isload=6
   1.112 @@ -173,11 +202,11 @@
   1.113  			next
   1.114  		}
   1.115  	}
   1.116 -	if (/version_string = /) isload=5
   1.117  	if (isload == 5) {  # LOAD.LST
   1.118  		sub(/ax,/,"bx,")
   1.119 -		if (/_version_string,/) isload=0
   1.120 +		if (/strcatb/) isload=0
   1.121  		if (/mov	bx,ax/) next
   1.122 +		sub(/,word ptr \[si\+29\]/,",cx")
   1.123  	}
   1.124  	if (/_base_himem\+2/ && is386 == 0) isload=4
   1.125  	if (isload == 4) {  # LOAD.LST
   1.126 @@ -192,11 +221,12 @@
   1.127  			sub(/cmp	/,"mov	cx,")
   1.128  		}
   1.129  		sub(/je/,"jcxz")
   1.130 -		if (/@strcpy/) isload=0
   1.131 +		if (/\+0x200/) isload=5
   1.132  	}
   1.133  	if (/void load_initrd\(\)/) isload=3
   1.134  	if (isload == 3) {  # LOAD.LST
   1.135  		if (/short @2@198/) sub(/@2@198/,"load_initrd_ret")
   1.136 +		if (/mov	ax,word ptr \[si\]/) $0="	lodsw"
   1.137  		if( /jmp/) {
   1.138  			print "load_initrd_ret:"
   1.139  			print "	pop	si"
   1.140 @@ -204,7 +234,7 @@
   1.141  			next
   1.142  		}
   1.143  		sub(/\[di/,"[bx")
   1.144 -		sub(/\di,/,"bx,")
   1.145 +		sub(/di,/,"bx,")
   1.146  	}
   1.147  	if (/vid_mode = vid_mode/) isload=2
   1.148  	if (isload == 2) {  # LOAD.LST
   1.149 @@ -212,7 +242,7 @@
   1.150  		sub(/je/,"jcxz")
   1.151  		if (/ax,word/) next
   1.152  		sub(/,ax/,",cx")
   1.153 -		if (/version_string/ || /starting linux 1\.3\.73/) isload=0
   1.154 +		if (/starting linux 1\.3\.73/) isload=0
   1.155  	}
   1.156  	if (/die\(not_kernel/ || /_rm_size=0x200/ || /heap_top = _rm_buf/) isload=1
   1.157  	if (isload == 1) {  # LOAD.LST
   1.158 @@ -894,5 +924,6 @@
   1.159  	if (afterjmp) print ";" $0
   1.160  	else print
   1.161  	if (/^	jmp	/ || /^	call	near ptr _boot_kernel/ ||
   1.162 -	    /^	call	near ptr @die$qpxzc/) afterjmp=1
   1.163 +	    /^	call	near ptr @die\$qpxzc/ ||
   1.164 +	    /^	call	near ptr @exit\$qv/) afterjmp=1
   1.165  }