Commit 6a4d2fff authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Fixed host application overwrite/data abort on wimpslot overrun.

  Fixed filetype failure (RISC OS build)
Detail:
  If the application memory limit for a squeezed application was large
    enough to hold the squeezed code but not large enough to hold the
    unsqueezed version without overwriting the calling application
    (eg.  the C compiler being too large to fit under amu), then
    everything would die nastily.  This fix to the unsqueeze code
    verifies that the calling program will not be overwritten and
    aborts the unsqueeze operation before disaster strikes.
  RISC OS builds remember to retype the file after saving.
Admin:
  Tested by forcing amu to launch a newly-squeezed cc image in the
    appropriate memory conditions, and cc generates an error before
    unsqueezing and killing amu.
  Verified that UnSqueezeAIF still recognises and patches the unsqueeze
    code for StrongARM compatibility.

Version 5.02. Tagged as 'squeeze-5_02'
parent 860636ca
/* (5.01)
/* (5.02)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 5.01
#define Module_MajorVersion_CMHG 5.02
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 22 Feb 1999
#define Module_Date_CMHG 11 Jun 1999
#define Module_MajorVersion "5.01"
#define Module_Version 501
#define Module_MajorVersion "5.02"
#define Module_Version 502
#define Module_MinorVersion ""
#define Module_Date "22 Feb 1999"
#define Module_Date "11 Jun 1999"
#define Module_FullVersion "5.02"
......@@ -39,6 +39,7 @@
#include <signal.h>
#ifdef __riscos
#include "kernel.h"
#include "swis.h"
#else
typedef struct {
int load, exec; /* load, exec addresses */
......@@ -863,6 +864,9 @@ static int squeeze(char *in, char *out)
#endif
if (wf_save(out, code, top - (char *)code) == -1)
err_fail("failed to write '%s'", out);
#ifdef __riscos
_swix(OS_File, _INR(0,2), 18, out, (info.load << 12) >> 20);
#endif
}
xfree(d);
#if DEBUGGING
......
......@@ -33,6 +33,7 @@
#ifdef __riscos
#include "kernel.h"
#include "swis.h"
#else
typedef struct {
int load, exec; /* load, exec addresses */
......@@ -274,6 +275,9 @@ static int xpand(char *in, char *out)
}
if (wf_save(out, (void *)info.start, info.end - info.start) == -1)
fatalerror("failed to write '%s'", out);
#ifdef __riscos
_swix(OS_File, _INR(0,2), 18, out, (info.load << 12) >> 20);
#endif
return(0);
}
......
......@@ -68,6 +68,16 @@ nShorts * 12
nLongs * 16
sizeToMove * 20
GBLL expand_memcheck
expand_memcheck SETL {TRUE}
[ expand_memcheck
GET hdr:ListOpts
GET hdr:Macros
GET hdr:System
GET hdr:MsgTrans
]
; Constants defining partition of nibble value space: these must match
; corresponding values in mod.squeeze.
......@@ -125,6 +135,13 @@ MinLong * 2
ADD R1, R11, R12 ; nLongs + nShorts
ADD R7, R6, R1, LSL #2 ; curFree += (nLongs + nShorts) * 4;
[ expand_memcheck
SWI OS_GetEnv
ADD R2,R7, #(8 + runImage - decodeImage)
CMP R1,R2
BLO expand_would_overwrite
]
MOV R5, R10 ; R5 is ptr into encoded tables
MOV R4, #0 ; this is the first table el
decodeTab
......@@ -227,6 +244,28 @@ moveCode
BLT moveCode
MOV PC, R4 ; jump to the new copy of the rest of the code
[ expand_memcheck
; If we were to let the expansion occur, either a data abort would
; occur, or we would overwrite our parent application.
expand_would_overwrite
ADR R0, error_block - 6 * 4
LDMIB R0!, {R1,R2,R4-R7}
SWI XMessageTrans_ErrorLookup
LDR R1,[R0]
TEQ R1, #0
ADRNE R0, error_block_failed
SWI OS_GenerateError
DCD 0, 0, 0, 0, 0
error_block
DCD 0
DCB "NoMem", 0
ALIGN
error_block_failed
DCD 0
DCB "Not enough memory", 0
ALIGN
]
decodeImage
; The code from here on gets executed only after it is copied
; elsewhere. This is confusing, but necessary.
......
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