mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 21:11:23 +02:00
Fixed stack checking for embedded target. Based on work by Christo Crause
git-svn-id: trunk@42157 -
(cherry picked from commit 2f501be2a0
)
This commit is contained in:
parent
915e48c675
commit
ebe4d4cf13
@ -113,6 +113,8 @@ function get_caller_frame(framebp:pointer;addr:pointer=nil):pointer;assembler;no
|
||||
{$define FPC_SYSTEM_HAS_SPTR}
|
||||
Function Sptr : pointer;assembler;nostackframe;
|
||||
asm
|
||||
in r24, 0x3d
|
||||
in r25, 0x3e
|
||||
end;
|
||||
|
||||
|
||||
|
@ -20,6 +20,8 @@ Unit System;
|
||||
interface
|
||||
{*****************************************************************************}
|
||||
|
||||
{$define FPC_SYSTEM_HAS_STACKTOP}
|
||||
|
||||
{$define FPC_IS_SYSTEM}
|
||||
{$define HAS_CMDLINE}
|
||||
|
||||
@ -202,6 +204,14 @@ const calculated_cmdline:Pchar=nil;
|
||||
{*****************************************************************************
|
||||
Misc. System Dependent Functions
|
||||
*****************************************************************************}
|
||||
var
|
||||
_stack_top: record end; external name '_stack_top';
|
||||
|
||||
function StackTop: pointer;
|
||||
begin
|
||||
StackTop:=@_stack_top;
|
||||
end;
|
||||
|
||||
|
||||
procedure haltproc;cdecl;external name '_haltproc';
|
||||
|
||||
@ -276,7 +286,7 @@ begin
|
||||
end;
|
||||
|
||||
var
|
||||
initialstkptr : Pointer; // external name '__stkptr';
|
||||
initialstkptr : record end; external name '_stack_top';
|
||||
{$endif FPC_HAS_FEATURE_STACKCHECK}
|
||||
|
||||
begin
|
||||
@ -293,7 +303,7 @@ begin
|
||||
|
||||
{$ifdef FPC_HAS_FEATURE_STACKCHECK}
|
||||
StackLength := CheckInitialStkLen(initialStkLen);
|
||||
StackBottom := initialstkptr - StackLength;
|
||||
StackBottom := @initialstkptr - StackLength;
|
||||
{$endif FPC_HAS_FEATURE_STACKCHECK}
|
||||
|
||||
{$ifdef FPC_HAS_FEATURE_EXCEPTIONS}
|
||||
|
@ -44,7 +44,11 @@ type
|
||||
{$endif FPC_HAS_FEATURE_TEXTIO}
|
||||
|
||||
const
|
||||
{$ifdef CPUAVR}
|
||||
STACK_MARGIN = 64; { Stack size margin for stack checking }
|
||||
{$else}
|
||||
STACK_MARGIN = 16384; { Stack size margin for stack checking }
|
||||
{$endif}
|
||||
{ Random / Randomize constants }
|
||||
OldRandSeed : Cardinal = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user