mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 19:49:31 +02:00
Fixed stack checking for embedded target. Based on work by Christo Crause
git-svn-id: trunk@42157 -
This commit is contained in:
parent
be7b653fef
commit
2f501be2a0
@ -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}
|
||||
|
||||
@ -203,6 +205,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';
|
||||
|
||||
@ -277,7 +287,7 @@ begin
|
||||
end;
|
||||
|
||||
var
|
||||
initialstkptr : Pointer; // external name '__stkptr';
|
||||
initialstkptr : record end; external name '_stack_top';
|
||||
{$endif FPC_HAS_FEATURE_STACKCHECK}
|
||||
|
||||
begin
|
||||
@ -294,7 +304,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