wok rev 21750

tazboot: shrink
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jun 15 16:18:19 2019 +0200 (2019-06-15)
parents 3d14781acd29
children 74a62a08433a
files linld/stuff/src/ISO9660.CPP linld/stuff/src/TAZBOOT.CPP linld/stuff/src/pipehole.awk
line diff
     1.1 --- a/linld/stuff/src/ISO9660.CPP	Fri Jun 14 17:38:01 2019 +0100
     1.2 +++ b/linld/stuff/src/ISO9660.CPP	Sat Jun 15 16:18:19 2019 +0200
     1.3 @@ -122,8 +122,7 @@
     1.4    next:
     1.5  	name = s;
     1.6  	do s++; while (*s != '/' && *s);
     1.7 -	c = *s;
     1.8 -	*s = 0;
     1.9 +	c = *s; *s = 0;
    1.10  	for (x->curdirsize = 0xFFFF; isoreaddir() != -1;) {
    1.11  		const char *n = name;
    1.12  #define i (x->tmp)
     2.1 --- a/linld/stuff/src/TAZBOOT.CPP	Fri Jun 14 17:38:01 2019 +0100
     2.2 +++ b/linld/stuff/src/TAZBOOT.CPP	Sat Jun 15 16:18:19 2019 +0200
     2.3 @@ -19,12 +19,12 @@
     2.4  
     2.5  static void next_chunk(struct image_himem *m)
     2.6  {
     2.7 +	if (m->state >= initrd_state.cnt) return;
     2.8  	struct initrd_info *i = &initrd_state.info[m->state];
     2.9  	m->chunk_size = 0;
    2.10 -	if (m->state >= initrd_state.cnt) return;
    2.11 -	lseekset2(m->fd,&i->ofs);
    2.12  	m->chunk_size = i->size;
    2.13  	m->state++;
    2.14 +	lseekset2(m->fd,&i->ofs);
    2.15  }
    2.16  
    2.17  static u32 isofilesize4round()
    2.18 @@ -35,9 +35,8 @@
    2.19  static void addinitrd()
    2.20  {
    2.21  	u16 *pcnt = &initrd_state.cnt;
    2.22 -	struct initrd_info *i = &initrd_state.info[*pcnt];
    2.23  	if (*pcnt >= MAXINITRD) return;
    2.24 -	++*pcnt;
    2.25 +	struct initrd_info *i = &initrd_state.info[(*pcnt)++];
    2.26  	i->size = isofilesize;
    2.27  	i->ofs = isofileofs;
    2.28  	initrd.size += isofilesize4round();
    2.29 @@ -76,7 +75,7 @@
    2.30  	skip_alloc++;
    2.31  	base_himem = memtop() /2;
    2.32  	//if (base_himem >= _64m) base_himem = _64m;
    2.33 -	if (* ((char *) &base_himem +3) >= 4) base_himem = _64m;
    2.34 +	if (* ((char *) &base_himem +3) >= 4) ((short *)&base_himem)[1] = _64m/_64k;
    2.35  	isoopen("boot") != -1 ||
    2.36  	isoopen("live") != -1 ||	// debian
    2.37  	isoopen("casper") != -1;	// ubuntu
    2.38 @@ -96,8 +95,8 @@
    2.39  			strcpy(fallback, x->filename);
    2.40  		if (strhead(x->filename, "rootfs") == -1
    2.41  			|| c > x->filename[6]) continue;
    2.42 +		c = x->filename[6];
    2.43  		strcpy(rootfs, x->filename);
    2.44 -		c = x->filename[6];
    2.45  	}
    2.46  
    2.47  	strcatb(buf_cmdline,"rw root=/dev/null autologin bootfrom=");
     3.1 --- a/linld/stuff/src/pipehole.awk	Fri Jun 14 17:38:01 2019 +0100
     3.2 +++ b/linld/stuff/src/pipehole.awk	Sat Jun 15 16:18:19 2019 +0200
     3.3 @@ -1,12 +1,20 @@
     3.4 -BEGIN { hold=0; is386=0; isload=0; isiso=0; wascall=0 }
     3.5 +BEGIN { hold=0; is386=0; isload=0; isiso=0; istazboot=0; wascall=0 }
     3.6  function isnum(n) { return match(n,/^[0-9+-]/) }
     3.7  {
     3.8  	sub(/segment word public/,"segment byte public")
     3.9  
    3.10  	if (/^@.*:$/ || /	endp$/) afterjmp=0
    3.11  	if (/dword ptr/) is386=1
    3.12 +	if (/vid_mode = vid_mode/) isload=2
    3.13 +	if (isload == 2) {  # LOAD.LST
    3.14 +		sub(/,0/,""); sub(/cmp	/,"mov	cx,")
    3.15 +		sub(/je/,"jcxz")
    3.16 +		if (/ax,word/) next
    3.17 +		sub(/,ax/,",cx")
    3.18 +		if (/version_string/) isload=0
    3.19 +	}
    3.20  	if (/heap_top = _rm_buf/) isload=1
    3.21 -	if (isload) {  # LOAD.LST
    3.22 +	if (isload == 1) {  # LOAD.LST
    3.23  		if (/mov	al,byte ptr/ && is386) {
    3.24  			print "	movzx	eax,byte ptr [si]"
    3.25  			next
    3.26 @@ -20,13 +28,13 @@
    3.27  		sub(/DGROUP:_isostate\+16/,"[si+16]")
    3.28  		if (/goto restarted/) isiso=0
    3.29  	}
    3.30 -	if (/c = \*s;/) isiso=3
    3.31 -	if (isiso == 3) { # ISO9660.LST
    3.32 +	if (/c = \*s; \*s = 0;/) isiso=3
    3.33 +	if (isiso == 3) { # ISO9660.LST, TAZBOOT.LST
    3.34  		if (/al,byte ptr/) {
    3.35  			print "	mov	al,0"
    3.36  			sub(/mov/,"xchg")
    3.37  		}
    3.38 -		if (/byte ptr \[di\],0/) {
    3.39 +		if (/byte ptr \[.*\],0/) {
    3.40  			isiso=0
    3.41  			next
    3.42  		}
    3.43 @@ -51,6 +59,77 @@
    3.44  		if (/jne	@@0$/) next
    3.45  		if (/jmp	@3@58$/) $0="	je	@3@58"
    3.46  	}
    3.47 +	if (/isoopen\(s\+7\) != -1/) isotazboot=8
    3.48 +	if (isotazboot == 8) { # TAZBOOT.LST
    3.49 +		if (/ax,si/) next
    3.50 +		sub(/ax,ax/,"si,si")
    3.51 +		if (/magic/) isotazboot=0
    3.52 +	}
    3.53 +	if (/\+\+isknoppix/) isotazboot=7
    3.54 +	if (isotazboot == 7) { # TAZBOOT.LST
    3.55 +		if (/al,byte/) sub (/al,byte ptr DGROUP:/,"bx,offset ")
    3.56 +		if (/inc/) sub (/al/,"word ptr [bx]")
    3.57 +		if (/,al/) next
    3.58 +		if (/isokernel/) isotazboot=0
    3.59 +	}
    3.60 +	if (/if \(c\) s\+\+;/) isotazboot=6
    3.61 +	if (isotazboot == 6) { # TAZBOOT.LST
    3.62 +		if (/cmp/) {
    3.63 +			$0="	cmp	al,0"
    3.64 +			isotazboot=0
    3.65 +		}
    3.66 +	}
    3.67 +	if (/initrd_state.info\[m->state\]/) isotazboot=5
    3.68 +	if (isotazboot == 5) { # TAZBOOT.LST
    3.69 +		if (/cx,ax/) $0="	xchg	ax,bx"
    3.70 +		if (/mov	ax,word ptr \[si\]/) $0="	lodsw"
    3.71 +		if (/ax,word ptr \[si\+28\]/) next
    3.72 +		if (/bx,cx/) next
    3.73 +		if (/endp/) isotazboot=0
    3.74 +	}
    3.75 +	if (/0x7FF0/) isotazboot=4
    3.76 +	if (isotazboot == 4) { # TAZBOOT.LST
    3.77 +		if (/ax,word ptr/) {
    3.78 +			print "	mov	ax,32752"
    3.79 +			sub(/mov/,"sub")
    3.80 +		}
    3.81 +		if (/bx,/ || /cx,/ || /dx,/) next
    3.82 +		sub(/,bx/,",0")
    3.83 +		sub(/,cx/,",ax")
    3.84 +		if (/short/) isotazboot=0
    3.85 +	}
    3.86 +	if (/c = x->filename/) isotazboot=3
    3.87 +	if (isotazboot == 3) { # TAZBOOT.LST
    3.88 +		if (/ax,/) $0="	xchg	ax,bx"
    3.89 +		if (/\]$/) next
    3.90 +		if (/@strcpy\$qpxzct1/) isotazboot=0
    3.91 +	}
    3.92 +	if (/memtop/) isotazboot=2
    3.93 +	if (isotazboot == 2) { # TAZBOOT.LST
    3.94 +		if (/DGROUP:_base_himem\+2,dx/) print "	mov	bx,offset _base_himem"
    3.95 +		sub(/DGROUP:_base_himem,/,"[bx],")
    3.96 +		sub(/DGROUP:_base_himem\+2,/,"[bx+2],")
    3.97 +		sub(/DGROUP:_base_himem\+3,/,"[bx+3],")
    3.98 +		if (/ax,word ptr \[bx\+2\]/ || /\[bp-4\],ax/) sub(/ax/,"bx")
    3.99 +		if (/bx,ax/) next
   3.100 +		if (/@strcmp\$qpxzct1/) isotazboot=0
   3.101 +	}
   3.102 +	if (/static void addinitrd/) isotazboot=1
   3.103 +	if (isotazboot == 1 || isotazboot == 100) { # TAZBOOT.LST
   3.104 +		if (/m->next_chunk = next_chunk/) isotazboot=100
   3.105 +		if (/load_initrd/) isotazboot=1
   3.106 +		if (/push	si/ && isotazboot == 1) next
   3.107 +		if (/pop	si/) next
   3.108 +		sub(/\[si\]/,"[bx]")
   3.109 +		sub(/si,/,"bx,")
   3.110 +		sub(/si\+/,"bx+")
   3.111 +		if (/mov	cx,ax/) $0="	xchg	ax,bx"
   3.112 +		if (/bx,cx/) next
   3.113 +		sub(/cx/,"bx")
   3.114 +		sub(/DGROUP:_imgs\+38/,"[bx+38]")
   3.115 +		sub(/DGROUP:_imgs\+40/,"[bx+40]")
   3.116 +		if (/static void bootiso/) isotazboot=0
   3.117 +	}
   3.118  	if (wascall) {
   3.119  		if (rcall != "") {
   3.120  			if (/,ax$/) 	print "	mov	" rcall ",ax"