# HG changeset patch # User Pascal Bellard # Date 1560608299 -7200 # Node ID c19368210c2bfc1f34b43d890c5e06039fd912c5 # Parent 3d14781acd29da5140a839aac486ada9b3f37ad8 tazboot: shrink diff -r 3d14781acd29 -r c19368210c2b linld/stuff/src/ISO9660.CPP --- a/linld/stuff/src/ISO9660.CPP Fri Jun 14 17:38:01 2019 +0100 +++ b/linld/stuff/src/ISO9660.CPP Sat Jun 15 16:18:19 2019 +0200 @@ -122,8 +122,7 @@ next: name = s; do s++; while (*s != '/' && *s); - c = *s; - *s = 0; + c = *s; *s = 0; for (x->curdirsize = 0xFFFF; isoreaddir() != -1;) { const char *n = name; #define i (x->tmp) diff -r 3d14781acd29 -r c19368210c2b linld/stuff/src/TAZBOOT.CPP --- a/linld/stuff/src/TAZBOOT.CPP Fri Jun 14 17:38:01 2019 +0100 +++ b/linld/stuff/src/TAZBOOT.CPP Sat Jun 15 16:18:19 2019 +0200 @@ -19,12 +19,12 @@ static void next_chunk(struct image_himem *m) { + if (m->state >= initrd_state.cnt) return; struct initrd_info *i = &initrd_state.info[m->state]; m->chunk_size = 0; - if (m->state >= initrd_state.cnt) return; - lseekset2(m->fd,&i->ofs); m->chunk_size = i->size; m->state++; + lseekset2(m->fd,&i->ofs); } static u32 isofilesize4round() @@ -35,9 +35,8 @@ static void addinitrd() { u16 *pcnt = &initrd_state.cnt; - struct initrd_info *i = &initrd_state.info[*pcnt]; if (*pcnt >= MAXINITRD) return; - ++*pcnt; + struct initrd_info *i = &initrd_state.info[(*pcnt)++]; i->size = isofilesize; i->ofs = isofileofs; initrd.size += isofilesize4round(); @@ -76,7 +75,7 @@ skip_alloc++; base_himem = memtop() /2; //if (base_himem >= _64m) base_himem = _64m; - if (* ((char *) &base_himem +3) >= 4) base_himem = _64m; + if (* ((char *) &base_himem +3) >= 4) ((short *)&base_himem)[1] = _64m/_64k; isoopen("boot") != -1 || isoopen("live") != -1 || // debian isoopen("casper") != -1; // ubuntu @@ -96,8 +95,8 @@ strcpy(fallback, x->filename); if (strhead(x->filename, "rootfs") == -1 || c > x->filename[6]) continue; + c = x->filename[6]; strcpy(rootfs, x->filename); - c = x->filename[6]; } strcatb(buf_cmdline,"rw root=/dev/null autologin bootfrom="); diff -r 3d14781acd29 -r c19368210c2b linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Fri Jun 14 17:38:01 2019 +0100 +++ b/linld/stuff/src/pipehole.awk Sat Jun 15 16:18:19 2019 +0200 @@ -1,12 +1,20 @@ -BEGIN { hold=0; is386=0; isload=0; isiso=0; wascall=0 } +BEGIN { hold=0; is386=0; isload=0; isiso=0; istazboot=0; wascall=0 } function isnum(n) { return match(n,/^[0-9+-]/) } { sub(/segment word public/,"segment byte public") if (/^@.*:$/ || / endp$/) afterjmp=0 if (/dword ptr/) is386=1 + if (/vid_mode = vid_mode/) isload=2 + if (isload == 2) { # LOAD.LST + sub(/,0/,""); sub(/cmp /,"mov cx,") + sub(/je/,"jcxz") + if (/ax,word/) next + sub(/,ax/,",cx") + if (/version_string/) isload=0 + } if (/heap_top = _rm_buf/) isload=1 - if (isload) { # LOAD.LST + if (isload == 1) { # LOAD.LST if (/mov al,byte ptr/ && is386) { print " movzx eax,byte ptr [si]" next @@ -20,13 +28,13 @@ sub(/DGROUP:_isostate\+16/,"[si+16]") if (/goto restarted/) isiso=0 } - if (/c = \*s;/) isiso=3 - if (isiso == 3) { # ISO9660.LST + if (/c = \*s; \*s = 0;/) isiso=3 + if (isiso == 3) { # ISO9660.LST, TAZBOOT.LST if (/al,byte ptr/) { print " mov al,0" sub(/mov/,"xchg") } - if (/byte ptr \[di\],0/) { + if (/byte ptr \[.*\],0/) { isiso=0 next } @@ -51,6 +59,77 @@ if (/jne @@0$/) next if (/jmp @3@58$/) $0=" je @3@58" } + if (/isoopen\(s\+7\) != -1/) isotazboot=8 + if (isotazboot == 8) { # TAZBOOT.LST + if (/ax,si/) next + sub(/ax,ax/,"si,si") + if (/magic/) isotazboot=0 + } + if (/\+\+isknoppix/) isotazboot=7 + if (isotazboot == 7) { # TAZBOOT.LST + if (/al,byte/) sub (/al,byte ptr DGROUP:/,"bx,offset ") + if (/inc/) sub (/al/,"word ptr [bx]") + if (/,al/) next + if (/isokernel/) isotazboot=0 + } + if (/if \(c\) s\+\+;/) isotazboot=6 + if (isotazboot == 6) { # TAZBOOT.LST + if (/cmp/) { + $0=" cmp al,0" + isotazboot=0 + } + } + if (/initrd_state.info\[m->state\]/) isotazboot=5 + if (isotazboot == 5) { # TAZBOOT.LST + if (/cx,ax/) $0=" xchg ax,bx" + if (/mov ax,word ptr \[si\]/) $0=" lodsw" + if (/ax,word ptr \[si\+28\]/) next + if (/bx,cx/) next + if (/endp/) isotazboot=0 + } + if (/0x7FF0/) isotazboot=4 + if (isotazboot == 4) { # TAZBOOT.LST + if (/ax,word ptr/) { + print " mov ax,32752" + sub(/mov/,"sub") + } + if (/bx,/ || /cx,/ || /dx,/) next + sub(/,bx/,",0") + sub(/,cx/,",ax") + if (/short/) isotazboot=0 + } + if (/c = x->filename/) isotazboot=3 + if (isotazboot == 3) { # TAZBOOT.LST + if (/ax,/) $0=" xchg ax,bx" + if (/\]$/) next + if (/@strcpy\$qpxzct1/) isotazboot=0 + } + if (/memtop/) isotazboot=2 + if (isotazboot == 2) { # TAZBOOT.LST + if (/DGROUP:_base_himem\+2,dx/) print " mov bx,offset _base_himem" + sub(/DGROUP:_base_himem,/,"[bx],") + sub(/DGROUP:_base_himem\+2,/,"[bx+2],") + sub(/DGROUP:_base_himem\+3,/,"[bx+3],") + if (/ax,word ptr \[bx\+2\]/ || /\[bp-4\],ax/) sub(/ax/,"bx") + if (/bx,ax/) next + if (/@strcmp\$qpxzct1/) isotazboot=0 + } + if (/static void addinitrd/) isotazboot=1 + if (isotazboot == 1 || isotazboot == 100) { # TAZBOOT.LST + if (/m->next_chunk = next_chunk/) isotazboot=100 + if (/load_initrd/) isotazboot=1 + if (/push si/ && isotazboot == 1) next + if (/pop si/) next + sub(/\[si\]/,"[bx]") + sub(/si,/,"bx,") + sub(/si\+/,"bx+") + if (/mov cx,ax/) $0=" xchg ax,bx" + if (/bx,cx/) next + sub(/cx/,"bx") + sub(/DGROUP:_imgs\+38/,"[bx+38]") + sub(/DGROUP:_imgs\+40/,"[bx+40]") + if (/static void bootiso/) isotazboot=0 + } if (wascall) { if (rcall != "") { if (/,ax$/) print " mov " rcall ",ax"