wok diff linld/stuff/src/pipehole.awk @ rev 21750
tazboot: shrink
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Jun 15 16:18:19 2019 +0200 (2019-06-15) |
parents | f9e283da869a |
children | 74a62a08433a |
line diff
1.1 --- a/linld/stuff/src/pipehole.awk Fri Jun 14 17:17:16 2019 +0200 1.2 +++ b/linld/stuff/src/pipehole.awk Sat Jun 15 16:18:19 2019 +0200 1.3 @@ -1,12 +1,20 @@ 1.4 -BEGIN { hold=0; is386=0; isload=0; isiso=0; wascall=0 } 1.5 +BEGIN { hold=0; is386=0; isload=0; isiso=0; istazboot=0; wascall=0 } 1.6 function isnum(n) { return match(n,/^[0-9+-]/) } 1.7 { 1.8 sub(/segment word public/,"segment byte public") 1.9 1.10 if (/^@.*:$/ || / endp$/) afterjmp=0 1.11 if (/dword ptr/) is386=1 1.12 + if (/vid_mode = vid_mode/) isload=2 1.13 + if (isload == 2) { # LOAD.LST 1.14 + sub(/,0/,""); sub(/cmp /,"mov cx,") 1.15 + sub(/je/,"jcxz") 1.16 + if (/ax,word/) next 1.17 + sub(/,ax/,",cx") 1.18 + if (/version_string/) isload=0 1.19 + } 1.20 if (/heap_top = _rm_buf/) isload=1 1.21 - if (isload) { # LOAD.LST 1.22 + if (isload == 1) { # LOAD.LST 1.23 if (/mov al,byte ptr/ && is386) { 1.24 print " movzx eax,byte ptr [si]" 1.25 next 1.26 @@ -20,13 +28,13 @@ 1.27 sub(/DGROUP:_isostate\+16/,"[si+16]") 1.28 if (/goto restarted/) isiso=0 1.29 } 1.30 - if (/c = \*s;/) isiso=3 1.31 - if (isiso == 3) { # ISO9660.LST 1.32 + if (/c = \*s; \*s = 0;/) isiso=3 1.33 + if (isiso == 3) { # ISO9660.LST, TAZBOOT.LST 1.34 if (/al,byte ptr/) { 1.35 print " mov al,0" 1.36 sub(/mov/,"xchg") 1.37 } 1.38 - if (/byte ptr \[di\],0/) { 1.39 + if (/byte ptr \[.*\],0/) { 1.40 isiso=0 1.41 next 1.42 } 1.43 @@ -51,6 +59,77 @@ 1.44 if (/jne @@0$/) next 1.45 if (/jmp @3@58$/) $0=" je @3@58" 1.46 } 1.47 + if (/isoopen\(s\+7\) != -1/) isotazboot=8 1.48 + if (isotazboot == 8) { # TAZBOOT.LST 1.49 + if (/ax,si/) next 1.50 + sub(/ax,ax/,"si,si") 1.51 + if (/magic/) isotazboot=0 1.52 + } 1.53 + if (/\+\+isknoppix/) isotazboot=7 1.54 + if (isotazboot == 7) { # TAZBOOT.LST 1.55 + if (/al,byte/) sub (/al,byte ptr DGROUP:/,"bx,offset ") 1.56 + if (/inc/) sub (/al/,"word ptr [bx]") 1.57 + if (/,al/) next 1.58 + if (/isokernel/) isotazboot=0 1.59 + } 1.60 + if (/if \(c\) s\+\+;/) isotazboot=6 1.61 + if (isotazboot == 6) { # TAZBOOT.LST 1.62 + if (/cmp/) { 1.63 + $0=" cmp al,0" 1.64 + isotazboot=0 1.65 + } 1.66 + } 1.67 + if (/initrd_state.info\[m->state\]/) isotazboot=5 1.68 + if (isotazboot == 5) { # TAZBOOT.LST 1.69 + if (/cx,ax/) $0=" xchg ax,bx" 1.70 + if (/mov ax,word ptr \[si\]/) $0=" lodsw" 1.71 + if (/ax,word ptr \[si\+28\]/) next 1.72 + if (/bx,cx/) next 1.73 + if (/endp/) isotazboot=0 1.74 + } 1.75 + if (/0x7FF0/) isotazboot=4 1.76 + if (isotazboot == 4) { # TAZBOOT.LST 1.77 + if (/ax,word ptr/) { 1.78 + print " mov ax,32752" 1.79 + sub(/mov/,"sub") 1.80 + } 1.81 + if (/bx,/ || /cx,/ || /dx,/) next 1.82 + sub(/,bx/,",0") 1.83 + sub(/,cx/,",ax") 1.84 + if (/short/) isotazboot=0 1.85 + } 1.86 + if (/c = x->filename/) isotazboot=3 1.87 + if (isotazboot == 3) { # TAZBOOT.LST 1.88 + if (/ax,/) $0=" xchg ax,bx" 1.89 + if (/\]$/) next 1.90 + if (/@strcpy\$qpxzct1/) isotazboot=0 1.91 + } 1.92 + if (/memtop/) isotazboot=2 1.93 + if (isotazboot == 2) { # TAZBOOT.LST 1.94 + if (/DGROUP:_base_himem\+2,dx/) print " mov bx,offset _base_himem" 1.95 + sub(/DGROUP:_base_himem,/,"[bx],") 1.96 + sub(/DGROUP:_base_himem\+2,/,"[bx+2],") 1.97 + sub(/DGROUP:_base_himem\+3,/,"[bx+3],") 1.98 + if (/ax,word ptr \[bx\+2\]/ || /\[bp-4\],ax/) sub(/ax/,"bx") 1.99 + if (/bx,ax/) next 1.100 + if (/@strcmp\$qpxzct1/) isotazboot=0 1.101 + } 1.102 + if (/static void addinitrd/) isotazboot=1 1.103 + if (isotazboot == 1 || isotazboot == 100) { # TAZBOOT.LST 1.104 + if (/m->next_chunk = next_chunk/) isotazboot=100 1.105 + if (/load_initrd/) isotazboot=1 1.106 + if (/push si/ && isotazboot == 1) next 1.107 + if (/pop si/) next 1.108 + sub(/\[si\]/,"[bx]") 1.109 + sub(/si,/,"bx,") 1.110 + sub(/si\+/,"bx+") 1.111 + if (/mov cx,ax/) $0=" xchg ax,bx" 1.112 + if (/bx,cx/) next 1.113 + sub(/cx/,"bx") 1.114 + sub(/DGROUP:_imgs\+38/,"[bx+38]") 1.115 + sub(/DGROUP:_imgs\+40/,"[bx+40]") 1.116 + if (/static void bootiso/) isotazboot=0 1.117 + } 1.118 if (wascall) { 1.119 if (rcall != "") { 1.120 if (/,ax$/) print " mov " rcall ",ax"