wok-current rev 24020

linld: fix iso9660/64
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Mar 06 18:15:05 2021 +0000 (2021-03-06)
parents 61df94a0fa43
children 010fc15e8b9d
files busybox/stuff/busybox-1.31-stat.u linld/stuff/src/CRTL.ASM linld/stuff/src/ISO9660.CPP linld/stuff/src/pipehole.awk
line diff
     1.1 --- a/busybox/stuff/busybox-1.31-stat.u	Sun Feb 28 16:32:57 2021 +0000
     1.2 +++ b/busybox/stuff/busybox-1.31-stat.u	Sat Mar 06 18:15:05 2021 +0000
     1.3 @@ -64,15 +64,13 @@
     1.4   		IF_FEATURE_STAT_FILESYSTEM("f")
     1.5   		IF_SELINUX("Z")
     1.6   		IF_FEATURE_STAT_FORMAT("c:")
     1.7 -@@ -786,6 +808,11 @@
     1.8 +@@ -786,6 +808,9 @@
     1.9   		selinux_or_die();
    1.10   	}
    1.11   #endif
    1.12 -+#if ENABLE_FEATURE_STAT_FILESYSTEM
    1.13  + 	if (opts & OPT_MAP) { /* -m */
    1.14  + 		statfunc = do_mapfile;
    1.15  +	}
    1.16 -+#endif
    1.17   	ok = 1;
    1.18   	argv += optind;
    1.19   	for (i = 0; argv[i]; ++i)
     2.1 --- a/linld/stuff/src/CRTL.ASM	Sun Feb 28 16:32:57 2021 +0000
     2.2 +++ b/linld/stuff/src/CRTL.ASM	Sat Mar 06 18:15:05 2021 +0000
     2.3 @@ -357,11 +357,8 @@
     2.4                  inc	bx
     2.5  		xchg	ax,bx
     2.6  		or	dl,dl			; clear C
     2.7 -		jz	failifc			; return 0
     2.8 +		jz	failifc			; return 0, bx=a tail
     2.9                  xor	dl,[bx]			; dl -= *a++
    2.10 -		ifdef BASIC_ISO9660
    2.11 -		and	dl,0dfh			; upcase
    2.12 -		endif
    2.13  		jne	fail			; return -1
    2.14                  inc	bx
    2.15                  jmp	@@loop
    2.16 @@ -397,6 +394,9 @@
    2.17                  inc	bx
    2.18  		xchg	ax,bx
    2.19                  xor	dl,[bx]			; dl ^= *a++
    2.20 +		ifndef  ROCKRIDGE
    2.21 +		and	dl,0dfh			; case insensitive
    2.22 +		endif
    2.23  		jne	fail			; return -1
    2.24                  inc	bx
    2.25  		or	dl,dl			; clear C
    2.26 @@ -747,14 +747,9 @@
    2.27  	ifdef ISO9660
    2.28  		ifndef	NO386
    2.29  		mov	eax,[_isostate.filesize]
    2.30 -@@end:
    2.31 -		mov	[(image_himem si).chunk_size],eax
    2.32  		else
    2.33  		mov	ax,[word _isostate.filesize]
    2.34  		mov	dx,[(word _isostate.filesize)+2]
    2.35 -@@end:
    2.36 -		mov	[word (image_himem si).chunk_size],ax
    2.37 -		mov	[word ((image_himem si).chunk_size)+2],dx
    2.38  		endif
    2.39  	else
    2.40  		mov	bl,02h			; SEEK_END
    2.41 @@ -764,8 +759,6 @@
    2.42  		mov	ax,[(image_himem si).fd]
    2.43  		call	rewind
    2.44  		pop	eax
    2.45 -@@end:
    2.46 -		mov	[(image_himem si).chunk_size],eax
    2.47  		else
    2.48  		push	ax
    2.49  		push	dx
    2.50 @@ -773,11 +766,15 @@
    2.51  		call	rewind
    2.52  		pop	dx
    2.53  		pop	ax
    2.54 +		endif
    2.55 +	endif
    2.56  @@end:
    2.57 +		ifndef	NO386
    2.58 +		mov	[(image_himem si).chunk_size],eax
    2.59 +		else
    2.60  		mov	[word (image_himem si).chunk_size],ax
    2.61  		mov	[word ((image_himem si).chunk_size)+2],dx
    2.62  		endif
    2.63 -	endif
    2.64  		ret
    2.65  
    2.66          endp    next_chunk
    2.67 @@ -1048,16 +1045,18 @@
    2.68          proc    @read_image$qp11image_himem near
    2.69  
    2.70  		push	di
    2.71 -		mov	di,4096
    2.72 -		push	di		; original size
    2.73 +		xor	di,di
    2.74  @@loop:
    2.75  		ifndef	NO386
    2.76 -		movzx	ecx,di
    2.77 +		xor	ecx,ecx
    2.78 +		mov	ch,4096/256
    2.79 +		sub	cx,di
    2.80  		mov	eax,[(image_himem si).chunk_size]
    2.81  		cmp	ecx,eax
    2.82  		jb	@@szok
    2.83  		else
    2.84 -		mov	cx,di
    2.85 +		mov	cx,4096
    2.86 +		sub	cx,di
    2.87  		mov	ax,[word (image_himem si).chunk_size]
    2.88  		cmp	cx,ax
    2.89  		jb	@@szok
    2.90 @@ -1067,49 +1066,43 @@
    2.91  		xchg	ax,cx
    2.92  @@szok:
    2.93  		jcxz	image_done
    2.94 -		mov	dx,offset _xfer_buf+4096
    2.95 -		sub	dx,di
    2.96 -		mov	bx,[si]
    2.97 +		lea	dx,[di+_xfer_buf]
    2.98 +		mov	bx,[(image_himem si).fd]
    2.99  		call	@read$cxdxbx
   2.100  		jb	image_done
   2.101 -		xor	cx,cx
   2.102 -		cwd				; ax < 8000h
   2.103 +		add	di,ax
   2.104  		ifndef	NO386
   2.105  		cwde				; ax < 8000h
   2.106 +		cdq
   2.107  		sub	[(image_himem si).chunk_size],eax
   2.108 -		xchg	eax,ebx
   2.109  		else
   2.110 +		cwd				; ax < 8000h
   2.111  		sub	[word (image_himem si).chunk_size],ax
   2.112 -		xchg	ax,bx
   2.113  		sbb	[word ((image_himem si).chunk_size)+2],dx
   2.114 -		jnz	@@fill
   2.115 -		cmp	[word (image_himem si).chunk_size],dx
   2.116  		endif
   2.117 -		jnz	@@fill
   2.118 -		dec	cx
   2.119  @@fill:
   2.120 -		test	bl,3
   2.121 +		test	al,3
   2.122  		je	@@filled
   2.123 -		mov	[bx+_xfer_buf],dh
   2.124 -		inc	bx
   2.125 +		mov	[di+_xfer_buf],dl
   2.126 +		inc	di
   2.127 +		inc	ax
   2.128  		jmp	@@fill
   2.129  @@filled:
   2.130  		ifndef	NO386
   2.131 -		sub	[(image_himem si).remaining],ebx
   2.132 +		sub	[(image_himem si).remaining],eax
   2.133 +		or	edx,[word (image_himem si).chunk_size]
   2.134  		else
   2.135 -		sub	[word (image_himem si).remaining],bx
   2.136 +		sub	[word (image_himem si).remaining],ax
   2.137  		sbb	[word ((image_himem si).remaining)+2],dx
   2.138 +		mov	ax,[word (image_himem si).chunk_size]
   2.139 +		or	ax,[word ((image_himem si).chunk_size)+2]
   2.140  		endif
   2.141 -		sub	di,bx
   2.142 -		pushf
   2.143 -		jcxz	@@same_chunk
   2.144 +		jnz	@@same_chunk
   2.145  		call	next_chunk
   2.146  @@same_chunk:
   2.147 -		popf
   2.148 -		jnz	@@loop
   2.149 +		jmp	@@loop
   2.150  image_done:
   2.151 -                pop	ax		; original size
   2.152 -		sub	ax,di
   2.153 +		xchg	ax,di
   2.154                  pop	di
   2.155  		ret
   2.156  
     3.1 --- a/linld/stuff/src/ISO9660.CPP	Sun Feb 28 16:32:57 2021 +0000
     3.2 +++ b/linld/stuff/src/ISO9660.CPP	Sat Mar 06 18:15:05 2021 +0000
     3.3 @@ -16,7 +16,7 @@
     3.4  }
     3.5  
     3.6  #if !defined(BASIC_ISO9660) && !defined(ROCKRIDGE)
     3.7 -#define  ROCKRIDGE
     3.8 +#define BASIC_ISO9660
     3.9  #endif
    3.10  static int isoreaddir(void)
    3.11  {
    3.12 @@ -37,16 +37,17 @@
    3.13  	if ((x->entrysize = * (short *) p) == 0) {
    3.14  		return -1;
    3.15  	}
    3.16 -	// x->filename = "";
    3.17 +	x->filemod = 0x81ED; if (p[25] & 2) ((char *)&(x->filemod))[1] = 0x41;
    3.18 +	register char *s;
    3.19  	x->filesize = * (unsigned long *) (p + 10);
    3.20 -	x->filemod = 0x81ED; if (p[25] & 2) ((char *)&(x->filemod))[1] = 0x41;
    3.21 +	s = ".."+1-p[33];
    3.22 +#ifdef ROCKRIDGE
    3.23  	p = x->buffer + 34 + ((p[32] + x->curpos) & -2);
    3.24  	x->curpos += x->entrysize;
    3.25 -#ifdef ROCKRIDGE
    3.26  	do {
    3.27  		register len = p[2];
    3.28  		if (* (short *) p == 0x4D4E) {
    3.29 -			x->filename = p + 5;
    3.30 +			s = p + 5;
    3.31  			p[len] = 0;
    3.32  			goto found;
    3.33  		}
    3.34 @@ -54,19 +55,21 @@
    3.35  	} while (x->buffer + x->curpos - 3 >= p);
    3.36  #endif
    3.37  #ifdef BASIC_ISO9660
    3.38 -	char *s;
    3.39 -	p = x->buffer + 33; p += x->curpos;
    3.40 -	s = ".."+1-p[0];
    3.41 -	p--;
    3.42 +# ifdef ROCKRIDGE
    3.43 +	p = x->buffer + 32 + x->curpos - x->entrysize;
    3.44 +# else
    3.45 +	x->curpos += x->entrysize;
    3.46 +	p += 32;
    3.47 +# endif
    3.48  	if (((* (short *) p) & 0xFEFF) -1 != 0) {
    3.49  		s = p + 1; p += *p;
    3.50  		if (* (short *) (p-1) != 0x313B) p+=2; // no ;1 to remove
    3.51  		if (*p != '.') p++;
    3.52  		*p = 0;
    3.53  	}
    3.54 -	x->filename = s;
    3.55  #endif
    3.56  found:
    3.57 +	x->filename = s;
    3.58  	return 0;
    3.59  }
    3.60  
    3.61 @@ -87,10 +90,6 @@
    3.62  #define _64bits (x->_64bits)
    3.63  	char *s;
    3.64  
    3.65 -#ifdef ISOHOOK
    3.66 -	_64bits = cpuhaslm();
    3.67 -  _32bits:
    3.68 -#endif
    3.69  	s = (char *) x->filename2open;
    3.70  	if (*s == '/') {
    3.71  		s++;
    3.72 @@ -99,10 +98,14 @@
    3.73  		//if (*(int*)(x->buffer+1) != 0x4443) return -1;
    3.74  	}
    3.75    next:
    3.76 -	isoreaddir_reset();
    3.77  	name = s;
    3.78  	do s++; while (*s && *s != '/');
    3.79  	c = *s; *s = 0;
    3.80 +#ifdef ISOHOOK
    3.81 +	_64bits = cpuhaslm();
    3.82 +  _32bits:
    3.83 +#endif
    3.84 +	isoreaddir_reset();
    3.85  	do {
    3.86  		if (isoreaddir() == -1) {
    3.87  #ifdef ISOHOOK
     4.1 --- a/linld/stuff/src/pipehole.awk	Sun Feb 28 16:32:57 2021 +0000
     4.2 +++ b/linld/stuff/src/pipehole.awk	Sat Mar 06 18:15:05 2021 +0000
     4.3 @@ -1,4 +1,4 @@
     4.4 -BEGIN { hold=0; is386=0; isload=0; isiso=0; istazboot=0; wascall=0; ishimem=0; label="none"; xlabel=""; file=""; retc="returnCz:\n" }
     4.5 +BEGIN { hold=0; is386=0; isload=0; isiso=0; istazboot=0; wascall=0; ishimem=0; label="none"; xlabel=""; file="" }
     4.6  function isnum(n) { return match(n,/^[0-9+-]/) }
     4.7  {
     4.8  	sub(/segment word public/,"segment byte public")
     4.9 @@ -245,32 +245,48 @@
    4.10  	 if (file == "iso9660.cpp") {
    4.11  	if (/ptr \[si\+8\],/) { si="si"; di="di" }
    4.12  	if (/ptr \[di\+8\],/) { si="di"; di="si" }
    4.13 -	if (/leave/ || /enter/) next
    4.14 +	if (/leave/ || /enter/ || /bp-2/ || /bp,sp/ || /push	bp/ || /sub	sp,/) next
    4.15  	if (/ptr \[.i\+10\],dx/) next
    4.16  	if (/ptr \[.i\+8\],ax/) next
    4.17  	if (/ptr \[.i\+8\],eax/) next
    4.18 -	if (/cx,word ptr \[.i\+32\]/) next
    4.19 +	if (/x,word ptr \[.i\+32\]/) next
    4.20  	if (/add	word ptr \[.i\],ax/) sub(/ax/,"cx")
    4.21  	if (/ax,word ptr \[si\+24\]/) sub(/mov	ax,/,"les	ax,d")
    4.22  	if (/ax,word ptr \[si\+26\]/) next
    4.23  	if (/word ptr \[si\+29\],ax/) sub(/ax/,"es")
    4.24  	if (/\[si\],-1/) $0="	not	word ptr [si]"
    4.25  	sub(/di,word ptr DGROUP:_isostate\+2/,"di,word ptr [si+2]")
    4.26 -	if (/s = p \+ 1;/ && !/ ;/) isiso=20
    4.27 +	if (/p = x->buffer \+ 32 \+ x->curpos/) isiso=21
    4.28 +#print "iso=" isiso " ; " $0
    4.29 +	if (isiso == 21) { # ISO9660.LST
    4.30 +		if (/si,ax/) next
    4.31 +		if (/ax,70/) {
    4.32 +			print "	lea	si,[bx+3+32]"
    4.33 +			$0="	sub	si,cx"
    4.34 +		}
    4.35 +		if (/# else/) isiso=0
    4.36 +	}
    4.37 +	if (/cx,si/) isiso=20
    4.38  	if (isiso == 20) { # ISO9660.LST
    4.39 +		if (/bx,dx/) {
    4.40 +			isiso=12
    4.41 +			next
    4.42 +		}
    4.43  		if (/al,byte ptr/) $0="	;inc	ax"
    4.44  		sub(/\[si-1\]/,"[si]")
    4.45  		if (/p != .\./) print "	inc	" di "	; see ;inc ax"
    4.46  		if (/i],0/) sub(/,0/,",ah")
    4.47 +		sub(/cx/,"dx")
    4.48  		if (/filename = s;/) {
    4.49 -			print "	stc"
    4.50  			isiso=0
    4.51  		}
    4.52  	}
    4.53  	if (isiso == 19) { # ISO9660.LST
    4.54  		if (/short @2@282/) $0="	jc	restoreC"
    4.55 -		if (/bp-2/ || /si\+34/ || /ax,dx/ || /cmp	ax,-1/) next
    4.56 -		sub(/dx,/,"bx,")
    4.57 +		if (/si\+34/ || /ax,dx/ || /ax,di/ || /cmp	ax,-1/ || /sub	ax,/) next
    4.58 +		sub(/dx,/,"ax,")
    4.59 +		if (/ax,word ptr \[si\+20\]/) sub(/ax/,"bx")
    4.60 +		if (/bx,offset/) sub(/bx/,"ax")
    4.61  		if (/short @2@282/) sub(/je/,"jnc")
    4.62  		if (/\[si\+37\],0/) sub(/,0/,",ch")
    4.63  		if (/@strcmp\$qpxzct1/) {
    4.64 @@ -307,6 +323,7 @@
    4.65  			print "	mov	bx,word ptr [si+9]"
    4.66  			print "	mov	ax,word ptr [si+13]"
    4.67  			print "setdirofsnsz:"
    4.68 +			print "	inc	di"
    4.69  			print "	mov	word ptr [si+26],bx"
    4.70  		}
    4.71  		if (/ax,/ || /si\+13/ || /si\+26/) next
    4.72 @@ -316,23 +333,30 @@
    4.73  	if (isiso != 15 && /si,offset DGROUP:_isostate/) $0=";" $0
    4.74  	if (isiso == 15) { # ISO9660.LST
    4.75  		if (/xor/) {
    4.76 +			print	"	stc"
    4.77  			print	"returnNotC:"
    4.78  			print	"	cmc"
    4.79 -			print	retc "returnC:"
    4.80 +			print	"returnC:"
    4.81  			print	"	sbb	ax,ax"
    4.82  			print	"return:"
    4.83  			next
    4.84  		}
    4.85 +		if (/i\+20\],cx/) sub(/cx/,"dx")
    4.86  		if (/@1@422:/ || /bp$/ || /bp,sp/ || /sp,2/) next
    4.87  		if (/\[di\],47/) isiso=17
    4.88  	}
    4.89  	if (/short @1@142/) { isiso=14; next }
    4.90  	if (isiso == 14) { # ISO9660.LST
    4.91  		if (/ax,-1/) next
    4.92 -		if (/jmp/) $0="	jb	returnCz"
    4.93 +		if (/jmp/) {
    4.94 +			print	"	JUMPS"
    4.95 +			print	"	jb	returnC"
    4.96 +			$0="	NOJUMPS"
    4.97 +		}
    4.98  	}
    4.99  	if (/p = x->buffer \+ 34/) isiso=13
   4.100  	if (isiso == 13) { # ISO9660.LST
   4.101 +		if (/cbw/) $0="	;cbw"
   4.102  		if (/i,.i/) $0="	xchg	ax,bx"
   4.103  		if (/i,ax/) $0="	lea	" di ",[bx+" si "+72]"
   4.104  		if (/i,72/ || /word ptr \[.i\+32\]/) next
   4.105 @@ -344,12 +368,13 @@
   4.106  		sub(/dx,ax/,"bh,0")
   4.107  		if (/bx,dx/) next
   4.108  		sub(/i,dx/,"i,bx")
   4.109 +		sub(/cx,/,"dx,")
   4.110  		if (/bx\+.i\],0/) sub(/,0/,",bh")
   4.111 -		if (/jmp/) {
   4.112 -			$0=retc "	jmp	returnC"
   4.113 -			retc=""
   4.114 -		}
   4.115 -		if (/while/) isiso=0
   4.116 +		if (/while/) isiso=120
   4.117 +	}
   4.118 +	if (isiso == 120) { # ISO9660.LST
   4.119 +		sub(/ax,/,"bx,")
   4.120 +		if (/endif/) isiso=0
   4.121  	}
   4.122  	if (/curpos >= SECT/) isiso=10
   4.123  	if (isiso == 10) { # ISO9660.LST
   4.124 @@ -378,7 +403,8 @@
   4.125  	if (isiso == 8) { # ISO9660.LST
   4.126  		if (/ax,/) next
   4.127  		sub(/mov	dx,/,"les	dx,d")
   4.128 -		sub(/,ax/,",es")
   4.129 +		sub(/\],ax/,"],es")
   4.130 +		sub(/cx,/,"dx,")
   4.131  		if (/filemod/) isiso=0
   4.132  	}
   4.133  	if (/entrysize =/) isiso=5
   4.134 @@ -405,7 +431,7 @@
   4.135  		sub(/cmp	byte ptr \[.i\]/,"sub	al")
   4.136  		if (/inc	/) { r=$2; print; next }
   4.137  		if (/al,0/) print "	mov	al,[" r "]"
   4.138 -		if (/al,byte ptr/) next
   4.139 +		if (/al,byte ptr \[/) next
   4.140  		if (/byte ptr \[.*\],0/) next
   4.141  	}
   4.142  	if (/ptr .isoreaddir/) isiso=1
   4.143 @@ -418,7 +444,6 @@
   4.144  		if (/short @2@366/) sub(/jne/,"jnc")
   4.145  		if (/short @2@282/) sub(/je/,"jc")
   4.146  		if (/short @2@562/) sub(/@2@562/,"returnNotC")
   4.147 -		if (/short @2@534/) { print; $0="	inc	cx" }
   4.148  		if (/ax,word ptr \[si\+4\]/) $0="	xchg	ax,bx	; " $0
   4.149  		if (/\[di\],al/) next
   4.150  		if (/@2@310/) next