wok-current diff linld/stuff/src/pipehole.awk @ rev 23989
syslinux: iso2exe/init should keep keyboard config
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Dec 05 09:55:13 2020 +0000 (2020-12-05) |
parents | 6b474fa55170 |
children | fb34bff6cff6 |
line diff
1.1 --- a/linld/stuff/src/pipehole.awk Thu Dec 03 09:39:27 2020 +0000 1.2 +++ b/linld/stuff/src/pipehole.awk Sat Dec 05 09:55:13 2020 +0000 1.3 @@ -55,25 +55,30 @@ 1.4 if (/do strcatb/) islinld=5 1.5 } # file == "linld.cpp" 1.6 if (file == "himem.cpp") { 1.7 + if (/sp,bp/ || /pop bp/) next 1.8 if (/void load_image/) ishimem=1 1.9 if (ishimem == 1 && is386 == 0) { 1.10 if (/si\+8\]$/ || /si\+4\]$/ || /si\+16\]$/) next 1.11 if (/si\+6\]$/ || /si\+2\]$/ || /si\+14\]$/) sub(/mov dx,/,"les dx,d") 1.12 - if (/si\+12\],ax/ || /si\+16\],ax/ || /bp-2\],ax/) sub(/,ax/,",es") 1.13 + if (/si\+12\],ax/ || /si\+16\],ax/ || /DGROUP:buf\+2,ax/) sub(/,ax/,",es") 1.14 + if (/dx,dword ptr \[si\+14\]/ || /DGROUP:buf,dx/) sub(/dx/,"ax") 1.15 } 1.16 if (ishimem == 1) { 1.17 if (/do \{/) ishimem=2 1.18 if (/byte ptr DGROUP:_vcpi,0/) print " mov bx,si" 1.19 - if (/bx,si/) next 1.20 - if (/sp,6/) { 1.21 - print " push si" 1.22 - print " push si" 1.23 + if (/bx,si/ || /push bp/ || /bp,sp/ || /push di/) next 1.24 + if (/sp,2/) { 1.25 next 1.26 } 1.27 + if (/bp\+4/) { 1.28 + print " global load_imagez:near" 1.29 + print "load_imagez:" 1.30 + $0=" xchg ax,si" 1.31 + } 1.32 } 1.33 if (ishimem == 2) { 1.34 if (/movzx/) print " cwde" 1.35 - if (/bp-6/) next 1.36 + if (/bp-2/ || /pop di/) next 1.37 if (/storepage.bufv/) { 1.38 print " inc ax" 1.39 print " push ax" 1.40 @@ -81,10 +86,28 @@ 1.41 if (/buf \+= size;/) { 1.42 print " pop ax" 1.43 } 1.44 - if (/Read error/) ishimem=0 1.45 + if (/endp/) ishimem=0 1.46 } 1.47 } # file == "himem.cpp" 1.48 if (file == "load.cpp") { 1.49 + if (/load_image\(/) { 1.50 + if (isload == 3) isload=13 1.51 + else isload=14 1.52 + } 1.53 + if (isload == 14) { # LOAD.LST 1.54 + if (/call/) { 1.55 + print " xchg ax,di" 1.56 + print " pop di" 1.57 + print " extrn load_imagez" 1.58 + $0=" jmp short load_imagez" 1.59 + } 1.60 + if (/ret/) isload=0 1.61 + if (/pop/ || /ret/ || /push/) next 1.62 + } 1.63 + if (isload == 13) { # LOAD.LST 1.64 + sub(/push /,"mov ax,") 1.65 + if (/pop/) { isload=3; next } 1.66 + } 1.67 if (/i\+21\],513$/) isload=11 1.68 if (isload == 12) { # LOAD.LST 1.69 if (/cmp/) next 1.70 @@ -138,20 +161,16 @@ 1.71 if (/\[0\] = m-\>fallback/) isload=6 1.72 if (isload == 6) { # LOAD.LST 1.73 if (/si\+2/) $0=" lodsw" 1.74 - if (/les/) sub(/bx,/,"ax,") 1.75 - if (/bx\+4/ || /es:/) { 1.76 - if (/bx\+4/) isload=0 1.77 + if (/les/) sub(/bx,/,"di,") 1.78 + if (/bx\+4/ || /es:/) next 1.79 + if (/si\+6/) { 1.80 + print " movsw" 1.81 + print " movsw" 1.82 + print " movsw" 1.83 + print " movsw" 1.84 next 1.85 } 1.86 - if (/si\+6/) { 1.87 - print " xchg ax,di" 1.88 - print " movsw" 1.89 - print " movsw" 1.90 - print " movsw" 1.91 - print " movsw" 1.92 - print " xchg ax,di" 1.93 - next 1.94 - } 1.95 + if (/ pop si/) print " pop di" 1.96 } 1.97 if (/version_string = /) isload=5 1.98 if (isload == 5) { # LOAD.LST 1.99 @@ -176,9 +195,15 @@ 1.100 } 1.101 if (/void load_initrd\(\)/) isload=3 1.102 if (isload == 3) { # LOAD.LST 1.103 - if(/push di/ || /pop di/) next 1.104 + if (/push si/) { print; $0=" push di" } 1.105 + if(/jmp/) next 1.106 sub(/\[di/,"[bx") 1.107 sub(/\di,/,"bx,") 1.108 + if (/@puts\$qpxzc/) { 1.109 + if (hold == 3) { print s; hold=0 } 1.110 + print " pop si" 1.111 + sub(/call/,"jmp") 1.112 + } 1.113 } 1.114 if (/vid_mode = vid_mode/) isload=2 1.115 if (isload == 2) { # LOAD.LST 1.116 @@ -203,6 +228,13 @@ 1.117 } 1.118 } # file == "load.cpp" 1.119 if (file == "iso9660.cpp") { 1.120 + if (/x->curpos \+= x->entrysize/) isiso=14 1.121 + if (isiso == 14) { # ISO9660.LST 1.122 + if (/ax,ax/) { 1.123 + print "return0:" 1.124 + isiso=0 1.125 + } 1.126 + } 1.127 if (/p = x->buffer \+ 34/) isiso=13 1.128 if (isiso == 13) { # ISO9660.LST 1.129 if (/di,si/) $0=" xchg ax,bx" 1.130 @@ -323,6 +355,8 @@ 1.131 if (/add word ptr \[si\+32\],ax/) $0=" add bx,word ptr [si+16]" 1.132 if (/al,/ || /,al/) sub(/al/,"cl") 1.133 if (/cmp byte ptr \[si\+34\],0/) $0=" or cl,cl" 1.134 + if (/ax,ax/) next 1.135 + if (/short @.@506/) $0=" jmp return0" 1.136 if (/jne @@0$/) next 1.137 if (/jmp @.@58$/) sub(/jmp/,"je") 1.138 sub(/mov ax,-1/,"dec ax")