Commit 5a56fcb7 authored by Kevin Bracey's avatar Kevin Bracey
Browse files

Compression of non-AIF images was broken.

xpand would correctly decompress old non-AIF images, and the broken non-AIF
images generated by recent versions of squeeze, but needed to be changed to
also decompress the new non-AIF images.
Memory limit check now always occurs if running in the application slot,
regardless of whether we were loaded at &8000 - the check was not performed
reliably for non-AIF images either.

Version 5.08. Tagged as 'squeeze-5_08'
parent c736be9d
/* (5.07) /* (5.08)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.64. * Last processed by srccommit version: 1.68.
* *
*/ */
#define Module_MajorVersion_CMHG 5.07 #define Module_MajorVersion_CMHG 5.08
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 02 Jul 2002 #define Module_Date_CMHG 15 Oct 2002
#define Module_MajorVersion "5.07" #define Module_MajorVersion "5.08"
#define Module_Version 507 #define Module_Version 508
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "02 Jul 2002" #define Module_Date "15 Oct 2002"
#define Module_ApplicationDate2 "02-Jul-02" #define Module_ApplicationDate "15-Oct-02"
#define Module_ApplicationDate4 "02-Jul-2002"
#define Module_ComponentName "squeeze" #define Module_ComponentName "squeeze"
#define Module_ComponentPath "RiscOS/Tools/Sources/squeeze" #define Module_ComponentPath "RiscOS/Tools/Sources/squeeze"
#define Module_FullVersion "5.07" #define Module_FullVersion "5.08"
#define Module_HelpVersion "5.07 (02 Jul 2002)" #define Module_HelpVersion "5.08 (15 Oct 2002)"
#define Module_LibraryVersionInfo "5:7" #define Module_LibraryVersionInfo "5:8"
...@@ -70,6 +70,8 @@ extern int *asmcall_exit; ...@@ -70,6 +70,8 @@ extern int *asmcall_exit;
static int debug; static int debug;
static int verbose; static int verbose;
#undef AIFPRELUDE /* musn't rely on this constant - it's changed over time */
/* /*
* Veneer on file-handling. * Veneer on file-handling.
*/ */
...@@ -143,6 +145,23 @@ static int immfield(word inst) { ...@@ -143,6 +145,23 @@ static int immfield(word inst) {
return ROR(val, shift); return ROR(val, shift);
} }
static SqueezeHeader *find_squeeze_header(int isaif, int *decompress)
{
/*
* The size of the decoded thing is stored 6 words before the
* start of the unsqueezing code (see squeeze.c).
*/
if (!isaif) {
/*
* Non-AIF images skip the first few instructions of the unsqueezing
* code; this has changed over time, so search backwards for
* MOV R0, #<imm>, which is always the first instruction
*/
while (((*decompress & 0xfffff000) != 0xe3a00000)) decompress--;
}
return (SqueezeHeader *) (decompress-SQUEEZEWORDS);
}
static int xpand(char *in, char *out) static int xpand(char *in, char *out)
{ _kernel_osfile_block info; { _kernel_osfile_block info;
bool isaif, isdata; bool isaif, isdata;
...@@ -198,14 +217,8 @@ static int xpand(char *in, char *out) ...@@ -198,14 +217,8 @@ static int xpand(char *in, char *out)
else else
isdata = NO, isaif = NO; isdata = NO, isaif = NO;
/*
* The size of the decoded thing is stored 6 words before the
* start of the unsqueezing code (see squeeze.c).
*/
{ int *decompress = &(((int *)hdr)[(hdr->bl_decompress & B_OFFSET) + PREFETCH]); { int *decompress = &(((int *)hdr)[(hdr->bl_decompress & B_OFFSET) + PREFETCH]);
SqueezeHeader *h = (SqueezeHeader *)(isaif ? decompress-SQUEEZEWORDS : SqueezeHeader *h = find_squeeze_header(isaif, decompress);
decompress-SQUEEZEWORDS-AIFPRELUDE);
int realsize = h->decodedsize; int realsize = h->decodedsize;
word *lastw = (word *)lastb - 1; word *lastw = (word *)lastb - 1;
......
...@@ -33,7 +33,7 @@ typedef struct aifhdr { ...@@ -33,7 +33,7 @@ typedef struct aifhdr {
#define AIFBYTES sizeof(aifhdr) /* size in bytes of an AIF header */ #define AIFBYTES sizeof(aifhdr) /* size in bytes of an AIF header */
#define AIFWORDS (AIFBYTES / sizeof(int)) #define AIFWORDS (AIFBYTES / sizeof(int))
#define AIFPRELUDE 3 /* no of extra instructions in AIF decompression */ #define AIFPRELUDE 5 /* no of extra instructions in AIF decompression */
#define PREFETCH 2 /* words of ARM prefetch */ #define PREFETCH 2 /* words of ARM prefetch */
typedef struct datahdr { typedef struct datahdr {
......
...@@ -104,6 +104,7 @@ MinLong * 2 ...@@ -104,6 +104,7 @@ MinLong * 2
|UnSqueeze_UnSqueezeBase| |UnSqueeze_UnSqueezeBase|
|UnsqueezeAIFImage| |UnsqueezeAIFImage|
; If it was an AIF image, we enter here and overwrite the BL decompress ; If it was an AIF image, we enter here and overwrite the BL decompress
; xpand relies on the first instruction here being MOV r0, #<imm>
MOV R0, #&E1000000 ; hex for instruction MOV r0, r0 MOV R0, #&E1000000 ; hex for instruction MOV r0, r0
ORR R0, R0, #&00A00000 ORR R0, R0, #&00A00000
SUB R1, LR, PC ; mode independent status bit removal SUB R1, LR, PC ; mode independent status bit removal
...@@ -111,6 +112,9 @@ MinLong * 2 ...@@ -111,6 +112,9 @@ MinLong * 2
STR R0, [R1, #-8]! ; overwrite the instruction we just BL'ed from STR R0, [R1, #-8]! ; overwrite the instruction we just BL'ed from
|UnsqueezeADFSImage| |UnsqueezeADFSImage|
[ UnsqueezeADFSImage - UnsqueezeAIFImage <> 5*4
! 1, "Change AIFPRELUDE in squeeze.h"
]
; We arrive here knowing very little about anything. ; We arrive here knowing very little about anything.
; First find out where we are, and where the tables start. ; First find out where we are, and where the tables start.
...@@ -129,25 +133,24 @@ MinLong * 2 ...@@ -129,25 +133,24 @@ MinLong * 2
; SWI &10 ; GetEnv - returns RAM limit in R1 ; SWI &10 ; GetEnv - returns RAM limit in R1
; SUB R6, R1, #&4000 ; grab 16K workspace, remember table base ; SUB R6, R1, #&4000 ; grab 16K workspace, remember table base
ADR R6, |UnSqueeze_UnSqueezeLimit|+8 ; top of squeezed image ADR R6, |UnSqueeze_UnSqueezeLimit|+24 ; top of squeezed image
CMP R6, R8 ; find highest of top of squeezed and unsqueezed image CMP R6, R8 ; find highest of top of squeezed and unsqueezed image
MOVLT R6, R8 ; use SWI if you prefer... (UNIX ?) MOVLO R6, R8 ; use SWI if you prefer... (UNIX ?)
[ expand_memcheck
TEQ r1, #&8000 ; AIF at &8000 - application?
]
; Allocate space for tables ; Allocate space for tables
ADD R1, R11, R12 ; nLongs + nShorts ADD R1, R11, R12 ; nLongs + nShorts
ADD R7, R6, R1, LSL #2 ; curFree += (nLongs + nShorts) * 4; ADD R7, R6, R1, LSL #2 ; curFree += (nLongs + nShorts) * 4;
[ expand_memcheck [ expand_memcheck
BNE %FT05 SWI OS_GetEnv ; returns RAM limit in R1
SWI OS_GetEnv ; R7 points to end of tables; add space required for copied-up
ADD R2,R7, #(8 + runImage - decodeImage) ; decode routine.
CMP R1,R2 ADD R2,R7, #|UnSqueeze_UnSqueezeLimit| + 24 - decodeImage
BLO expand_would_overwrite ; if PC < the RAM limit, and R2 > the RAM limit, we're in trouble
05 ; (if PC > the RAM limit, we assume we're not in the application slot)
CMP PC,R1
CMPLO R1,R2
BLO expand_would_overwrite
] ]
MOV R5, R10 ; R5 is ptr into encoded tables MOV R5, R10 ; R5 is ptr into encoded tables
...@@ -264,21 +267,21 @@ moveCode ...@@ -264,21 +267,21 @@ moveCode
; If we were to let the expansion occur, either a data abort would ; If we were to let the expansion occur, either a data abort would
; occur, or we would overwrite our parent application. ; occur, or we would overwrite our parent application.
expand_would_overwrite expand_would_overwrite
ADR R0, error_block - 6 * 4 ADR R0, error_block - 6 * 4
LDMIB R0!, {R1,R2,R4-R7} LDMIB R0!, {R1,R2,R4-R7}
SWI XMessageTrans_ErrorLookup SWI XMessageTrans_ErrorLookup
LDR R1,[R0] LDR R1,[R0]
TEQ R1, #0 TEQ R1, #0
ADRNE R0, error_block_failed ADRNE R0, error_block_failed
SWI OS_GenerateError SWI OS_GenerateError
DCD 0, 0, 0, 0, 0 DCD 0, 0, 0, 0, 0
error_block error_block
DCD 0 DCD 0
DCB "NoMem", 0 DCB "NoMem", 0
ALIGN ALIGN
error_block_failed error_block_failed
DCD 0 DCD 0
DCB "Not enough memory", 0 DCB "Not enough memory", 0
ALIGN ALIGN
] ]
...@@ -325,7 +328,7 @@ long0 ...@@ -325,7 +328,7 @@ long0
LDR R0, [R11, R0, LSL #2] ; w = longs[(nibble-2)<<8 | *p--] LDR R0, [R11, R0, LSL #2] ; w = longs[(nibble-2)<<8 | *p--]
LDRB R1, [R10, #-1]! LDRB R1, [R10, #-1]!
ORR R4, R1, R0, LSL #8 ORR R4, R1, R0, LSL #8
B gotFirst B gotFirst
notlong0 notlong0
MOVS R4, R3 ; TMD 13-Feb-90: combine 2 instructions here MOVS R4, R3 ; TMD 13-Feb-90: combine 2 instructions here
; used to be CMPS R3,#0; MOVEQ R4,R3 ; used to be CMPS R3,#0; MOVEQ R4,R3
...@@ -379,7 +382,7 @@ literal1 ; the longer path ? ...@@ -379,7 +382,7 @@ literal1 ; the longer path ?
LDRB R1, [R10, #-1]! ; given in ARM CPU Manual. LDRB R1, [R10, #-1]! ; given in ARM CPU Manual.
ORR R5, R0, R1, LSL #24 ORR R5, R0, R1, LSL #24
STMDB R8!, {R4,R5} STMDB R8!, {R4,R5}
B decodePair B decodePair
doneDecode doneDecode
CMPS R13, #0 ; Any data need to be copied elsewhere ? CMPS R13, #0 ; Any data need to be copied elsewhere ?
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment