Commit ddf71cb7 authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Stack extension return code is now APCS variant safe.

Detail:
  Extension exit code relied on the user function preserving the
    Z flag across the function call.  This no longer happens.
Admin:
  Work in progress.

Version 4.97, 4.12.2.2. Tagged as 'RISC_OSLib-4_97-4_12_2_2'
parent 323e58bd
......@@ -8,7 +8,7 @@
GBLS Module_FullVersion
Module_MajorVersion SETS "4.97"
Module_Version SETA 497
Module_MinorVersion SETS "4.12.2.1"
Module_Date SETS "08 Nov 1999"
Module_FullVersion SETS "4.97 (4.12.2.1)"
Module_MinorVersion SETS "4.12.2.2"
Module_Date SETS "09 Nov 1999"
Module_FullVersion SETS "4.97 (4.12.2.2)"
END
......@@ -4,12 +4,12 @@
*
*/
#define Module_MajorVersion_CMHG 4.97
#define Module_MinorVersion_CMHG 4.12.2.1
#define Module_Date_CMHG 08 Nov 1999
#define Module_MinorVersion_CMHG 4.12.2.2
#define Module_Date_CMHG 09 Nov 1999
#define Module_MajorVersion "4.97"
#define Module_Version 497
#define Module_MinorVersion "4.12.2.1"
#define Module_Date "08 Nov 1999"
#define Module_MinorVersion "4.12.2.2"
#define Module_Date "09 Nov 1999"
#define Module_FullVersion "4.97 (4.12.2.1)"
#define Module_FullVersion "4.97 (4.12.2.2)"
......@@ -2541,7 +2541,11 @@ alloc_return_block
ADR v6, StkOvfPseudoEntry+12
]
STMDA a1, {v3-v6} ; new return frame in old chunk...
ADR lr, StackOverflowExit
LoadStaticAddress APCS_A_Client, v1, v2
LDRB v1, [v1] ; determine which exit routine to use
TEQ v1, #0
ADREQ lr, StackOverflowExit ; non APCS-A
ADRNE lr, StackOverflowExitA ; APCS-A
MOV a2, sp ; saved sp in old frame = NEW sp
; (otherwise exit call is fatal)
STMDB fp, {a1, a2, lr} ; pervert old frame to return here...
......@@ -2602,7 +2606,11 @@ DoneArgumentCopy
MOV v1, fp ; old chunk's frame pointer
SUB ip, v4, #SC_SLOffset ; needed frame size, no margin
LDMDA v1!, {a1, a2, v2-v6} ; 1st 7 of possible 14 saved regs
ADR v5, StackOverflowExit ; return address...
LoadStaticAddress APCS_A_Client, v5, v4
LDRB v5, [v5]
TEQ v5, #0
ADREQ v5, StackOverflowExit ; return address... (non APCS-A)
ADRNE v5, StackOverflowExitA ; return address... (APCS-A)
MOV v4, sp ; SP in NEW chunk
ORR v3, fp, #ChunkChange ; new FP in old chunk
SUB fp, sp, #4 ; FP in new chunk
......@@ -2629,6 +2637,15 @@ DoneArgumentCopy
StkOvfPseudoEntry
STMFD sp!, {fp, ip, lr, pc} ; A register save mask
StackOverFlowExitA Keep
; We return here when returning from an APCS_A function - perform the register
; munging
MOV fp, r10
MOV sl, r13
MOV sp, r12
MOV r14, #PSRZBit ; ensure register munging on exit
B StackOverflowExitCommon
StackOverflowExit Keep
; We return here when returning from the procedure which caused the
; stack to be extended. FP is in the old chunk SP and SL are still
......@@ -2638,11 +2655,8 @@ StackOverflowExit Keep
; stack-description registers here and permute them back at the end.
; We do not do the expected ..EQ operations here, in order to keep the
; event handler happy - APCS change expected to be unconditional or NE.
MOV r14, pc
TST r14, #PSRZBit
MOVNE fp, r10
MOVNE sl, r13
MOVNE sp, r12
MOV r14, #0 ; don't munge registers later on
StackOverflowExitCommon
; We need to move sp and sl back into the old chunk. Since this happens
; in two operations, we need precautions against events while we're
; doing it.
......@@ -2665,12 +2679,14 @@ DeallocateChunkLoop
LDR v3, [v2, #SC_next] ; next chunk
MOV a1, v2
LDR ip, [v2,#SC_deallocate] ; deallocate proc for this chunk
CMPS ip, #0 ; if there is one...
MOV lr, pc
MOVNE pc, ip ; then call it...
MOVNE a2, #0
STRNE a2, [v1, #SC_next-SC_SLOffset] ; and unhook next chunk
CMPS ip, #0 ; is there a proc?
MOVEQ v1, v2 ; no deallocate proc: try next chunk
BEQ DeallocateChunkLoopSkip ; go around next chunk
MOV lr, pc
MOV pc, ip ; there was, so call it...
MOV a2, #0
STR a2, [v1, #SC_next-SC_SLOffset] ; and unhook next chunk
DeallocateChunkLoopSkip
MOV v2, v3
B DeallocateChunkLoop
DoneDeallocateChunks
......
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